Permalink
Browse files

google helper spark

  • Loading branch information...
0 parents commit febcfb59acfbb09c43c3cf341d43fa268efc8870 Michiel Vugteveen committed Sep 24, 2011
Showing with 54 additions and 0 deletions.
  1. +7 −0 config/autoload.php
  2. +4 −0 config/googlehelper.php
  3. +24 −0 helpers/google_helper.php
  4. +19 −0 spark.info
@@ -0,0 +1,7 @@
+<?php
+
+# Load the config when the spark is loaded
+//$autoload['config'] = array('analytics');
+
+# Load the following helpers when the spark is loaded
+$autoload['helper'] = array('google_helper');
@@ -0,0 +1,4 @@
+<?php
+
+# The account ID for Google Analytics
+$config['analytics_id'] = '';
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * Helper to generate a Google Analytics trackingcode
+ * @param string $analytics_id The Google Analytics ID
+ * @return string Tracking Code for Google
+*/
+function analytics_trackingcode($analytics_id='')
+{
+ $analytics_id = ($analytics_id) ? $analytics_id : config_item('analytics_id');
+
+ $trackingcode = "<script type=\"text/javascript\">
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', '".$analytics_id."']);
+ _gaq.push(['_trackPageview']);
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+</script>";
+
+ return $trackingcode;
+}
@@ -0,0 +1,19 @@
+# This is the spark-sdk specification. It's in a magical format called YAML.
+# Use this format while developing your own sparks!
+
+# This is the spark name. This should be the registered name of the spark.
+# It is here for informational purposes only.
+name: googlehelper
+
+# This is the current version of this spark. All sparks should be in
+# x.x.x format. Validation will fail otherwise.
+version: 0.0.1
+
+# This is the version of CodeIgniter this spark is compatible up to. It should
+# be in x.x.x format
+compatibility: 2.0.2
+
+# There are no dependencies now, but when there are, uncomment below.
+#dependencies:
+# some-spark-1: 1.0.0
+# some-other-spark-2: 1.0.0

0 comments on commit febcfb5

Please sign in to comment.