Google Analytics Help

ocdadam
ocdadam Community Member Posts: 2
Hello everyone!



I was hoping I could get some guidance on how to add the google analytics tracking scripts to my pages.

I tried the suggestion provided by Dr. Lectora on another thread (Using External HTML Object -> Type:Other on the title level) however, I think the google analytics tracking script may have changed since that post, so that method doesn't seem to work. I also tried each type of External HTML object to no avail. Any suggestions?



Thanks in advance!

Comments

  • canadian
    canadian Community Member Posts: 12

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'TRACKING-CODE-HERE']);
    _gaq.push(['_setCustomVar', 1, 'Module', 'MODULE TITLE HERE', 3]);
    _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);
    })();
    [/CODE]

    Replace TRACKING-CODE-HERE with your Google UA-#### number
    I chose to make a custom Variable to see which modules were being loaded. I had to create a custom module dashboard to view the results in google analytics. Replace MODULE TITLE HERE with whatever you title your course.

    Put this External HTML at the top of your project tree so it is loaded on every page. I resized the actual external HTML object in my project to the bottom corner really tiny so it's out of the way when editing a project.[CODE]

    var _gaq = _gaq || [];

    _gaq.push();

    _gaq.push();

    _gaq.push();

    (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);

    })();

    [/CODE]



    Replace TRACKING-CODE-HERE with your Google UA-#### number

    I chose to make a custom Variable to see which modules were being loaded. I had to create a custom module dashboard to view the results in google analytics. Replace MODULE TITLE HERE with whatever you title your course.



    Put this External HTML at the top of your project tree so it is loaded on every page. I resized the actual external HTML object in my project to the bottom corner really tiny so it's out of the way when editing a project.
  • ocdadam
    ocdadam Community Member Posts: 2
    Thanks for the reply! I appreciate the help. A couple more quick questions...



    Is the external HTML type Other?



    Is the custom variable component necessary? Can I exclude this line:

    _gaq.push();

    If I just put it at the title level, will it track every page?



    Thanks!
  • canadian
    canadian Community Member Posts: 12
    yes the type is Other.



    no you do not need that line. I only include it so I know exactly how many times a specific module is launched and how long it's taking to complete.



    If you just want overall stats you don't need it. There is more information posted on google's site: https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables#setup