Analytics

Analytics are easy to set up. Follow the steps below:

Adding an Analytics Account

  1. Open the analytics file by going _resources->includes->analytics.inc
  2. Copy and paste the tracking code from Google Analytics. It should look something like:

    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-00000000-1', 'auto');
    ga('send', 'pageview');

    </script>

  3. Remove the first "paragraph". It should look like:

    <script>
    ga('create', 'UA-00000000-1', 'auto');
    ga('send', 'pageview');
    </script>

  4. If that's the only script on your site, you're done. If you're adding a secondary analytics code, you have to add a name like so:

    <script>
    ga('create', 'UA-00000000-1', {'name': 'somethinghere'});
    ga('somethinghere.send', 'pageview');
    </script>

    The name can be anything, just make sure it matches on the 'create' line and the 'send' line.

Adding Events

  1. Add the following code to an onclick event:

    ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);

  2. Be sure to change the items in brackets to your own values
  3. If you have more than one analytics account on the page, be sure to use the name for the account you want to use.

    For first analytics:
    ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);

    For all other analytics:
    ga('somethinghere.send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);
©