Where to add the Google Analytics script to a Web App Builder (on locally hosted server) site?

5041
4
Jump to solution
09-15-2015 10:23 AM
JasonBuck
New Contributor III

I am trying to add the Google Analytics script to a locally hosted Web App Builder site.  I've put the script in the Index.html file.  According to the  network traffic the site is sending information to Google Analytics, however, no users are being logged.  Is using Google Analytics with a web app builder site allowed or has anyone gotten this to work?  If so, is there a specific location where the script needs to be placed?  Thank you.

Jason Buck

La Crosse, WI

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Jason,

   I have this in the head section of my index.html and I get analytic data.

  <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i=i||function(){
    (i.q=i.q||[]).push(arguments)},i.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-My code', 'auto');
    ga('send', 'pageview');

  </script>

View solution in original post

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Jason,

   I have this in the head section of my index.html and I get analytic data.

  <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i=i||function(){
    (i.q=i.q||[]).push(arguments)},i.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-My code', 'auto');
    ga('send', 'pageview');

  </script>
0 Kudos
JasonBuck
New Contributor III

Robert,

Thank you.  That's where I have it as well.  After checking Google Analytics again, I just realized that the date range being displayed didn't include today.  It was actually tracking.  Thank you for the confirmation on the script location.

Jason

IanGrasshoff
Occasional Contributor

Hey Jason!

I happened to stumble across this thread.  Thought you might find this useful for the future

GitHub - igrasshoff/esri-wab-widget-google-analytics: A google analytics widget & template for use i... 

mohannainar1
New Contributor III

Hi Robert,

I found a widget https://github.com/igrasshoff/esri-wab-widget-google-analytics. Do you have any idea on this. 

I added the widget in WAB developer edition. When I launch the application not able to view the widget

 

0 Kudos