hello i trying to incorporate google analytics through my application that i have created using tidesdk. i have the standard javascript includes that you would usually use in a website however. i cant seem to get this to work.
(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-41910717-2');
ga('send', 'pageview');
when i check the alalytics page i do not see any activity.
has anyone ever done this is it even possible.
Did you include the script tags? Also, are you placing it in between your head tags? If you use firebug or chrome developer tools, you should be able to see the analytics.js code loading. Do you see that?
<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-41910717-2');
ga('send', 'pageview');
</script>
Related
I'm trying to add Google Analytics to hundreds of pages of HTML. Theres no CMS as of yet, just static HTML pages.
I noticed all pages had:
<script type='text/javascript' src='http://www.easy.com/wp-includes/js/jquery/jquery.js'></script>
Can I just add my Google Analytics code in there?
<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','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXX-1', 'auto');
ga('send', 'pageview');
</script>
Or does it have to be in a file with a specific name like analytics.js?
Adding GA to the page requires the HIGHLY recommended code snippet:
<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','https://www.google-analytics.com/analytics.js','ga');
</script>
so that you'll always have the latest library. If you host the analytics.js library yourself, you may not get any updates pushed out to you. The snippet can also be hosted in a file that gets included on every page of your site as well.
What are the limiations to using Universal Analytics when placed into a .js file at the and can it result in a decrease of pageviews?
I am using the below UA code with Demographics "displayfeatures" enabled. I noticed traffic numbers declined, but I don't understand why I can't use an external .js. Any thoughts?
(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', 'INSERT UA CODE', 'INSERT SITENAME');
ga('require', 'displayfeatures');
ga('send', 'pageview');
Previously, I'm using traditional ga.js to track the visitors who click on a link.
donating
However, I'm just migrating to Google Universal Analytics.
<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-43627934-1', 'jstock.org');
ga('send', 'pageview');
</script>
What is the proper way to perform equivalent pageTracker._trackPageview?
ga('send', 'pageview', '/my-overridden-page?id=1');
Basically,
ga('send', 'pageview', 'page path');
Check out this link for migration examples:
https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs
I am using the new Google Analytics code (below) and need it to be able to track # URLs. I can do it in the old tracking code but am unshure of how to do it in this new code. Ideally I would love to be able to stick the tracking code into the header of all pages without modification and have it grab the # from the URL. Any help would be greatly appreciated. I have check out this page https://developers.google.com/analytics/devguides/collection/analyticsjs/pages but am still unsure of exactly how to do what I want.
(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-2433430-6', 'mydomain.org');
ga('require', 'linkid', 'linkid.js');
ga('send', 'pageview');
ga('create', 'UA-XXXX-Y', {'allowAnchor': false});
from here : https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#allowAnchor
Long story short, i have two website url's
www.somewebsiteA.com
www.somewebsiteB.com
Both domains point to the same server.
I created a google analytics account, and setup the two urls and have individual analytics keys for them.
Is this how i should paste the google code into the pages?
<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-12345678-1', 'somewebsiteA.com');
ga('send', 'pageview');
ga('create', 'UA-12345678-2', 'somewebsiteB.com');
ga('send', 'pageview');
</script>
I'm not entirely certain. It seems like somewebsiteB.com isnt working.
Thanks!
You need to give each one their own namespace:
<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-12345678-1', {'cookieDomain':'somewebsiteA.com', 'name':'siteA'});
ga('siteA.send', 'pageview');
ga('create', 'UA-12345678-2', {'cookieDomain':'somewebsiteB.com','name':'siteB'});
ga('siteB.send', 'pageview');
</script>