Forum Discussion

JulioPalacios's avatar
JulioPalacios
Community Member
4 years ago

Can't seem to get Google Analytics to work with my Story

Wondering if anyone can assist me understand why I can't seem to get Google Analytics to work with my story. 

I think I have a pretty good handle on the process where I need to embed code in my story.html file (in the <head> section)

I've tried the following formats but have not been able to see my usage reflect on my google analytics dashboard. 

I tried using the global tag provided by Google (measurement ID altered for privacy):

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-K7G2L9ZBTV"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-K7G2L9ZBTV');
</script>

I've also tried:

<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'G-K7G2L9ZBTV', 'auto');
ga('set', 'appName', 'Google Analytics Example');
</script>
<script async src="https://www.google-analytics.com/analytics.js"></script>

as per advised here

neither seems to work. 

Although it seems like a fever dream at this point, I was able to briefly get the page visit tracking to work, but in my process of getting event tracking set up I broke things. 

Any advice would be appreciated. I can also answer any questions to help clarify the steps i've taken. 

 

  • At my previous job, I used to use Google Analytics quite a bit to track pages and events.  I found that the GA code needs to go in the header of the Story.html file AND the LMS one.  I hope that helps.

    • JulioPalacios's avatar
      JulioPalacios
      Community Member

      Oh that's good to know! Thanks. I think I found the culprit of my confusion. Turns out GitHub restricts GA analytics. Moved it to a different server and it seems to work now.

  • I also use SCORM Cloud to test my modules and Google Analytics.  It's free and easy to use.