Migrate pageTracker._trackPageview to Google Universal Analytics - google-analytics

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

Related

Two Google Analtyics profiles in same same tracking script not working

We have two profiles that we are tracking for the same site and only one account is working.
Getting the following error in the second GA profile, but I've confirmed code is correct:
Property http://www.ourwebsite.com is not receiving hits. Either your
site is not receiving any sessions or it is not tagged correctly.
Is there anything wrong with this?
Here's the following code I'm using:
<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-########-1', 'auto');
ga('create', 'UA-########-1', 'auto', {'name': 'newTracker'});
ga('send', 'pageview');
ga('newTracker.send', 'pageview');
</script>

google analytics data is not showing up - Tracking not installed

I have a problem with google analytics for web.
I installed the analytics as following just before the closing head tag.
<script type="text/javascript">
(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-xxxx23-1', 'auto');
ga('create', 'UA-xxxx56-2', 'auto');
ga('send', 'pageview');
</script>
It is weird because on one UA code (the one that is uncommented) no data is coming through ans the status of the tracking code is "tracker is not installed".
While the other property on another account the data is coming in correctly and the status is "Receiving data".
Any idea what this problem might be?
Turns out it was a time issue. The settings took around a day to kick in. The weird thing was that no realtime data was coming through. But now it works. If anyone has the same problem, just be patient.
If you are using multiple tracking ID then you have to pass the name field as the fourth argument in the create command.
ga('create', 'UA-XXXXX-Y', 'auto', 'myTracker');
And then you have to prefix the command name with the tracker name, followed by a dot.
ga('myTracker.send', 'pageview');
finally your code will look like this with double tracker
(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-xxxxxxxx-1', 'auto');
ga('create', 'UA-xxxxxxxx-1', 'auto', 'clientTracker');
ga('send', 'pageview');
ga('clientTracker.send', 'pageview');

Use Hastag # in Google Analytics New analytics.js tracking code

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

setting up dual google analytics on 1 website

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>

tidesdk google analytics implementation

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>

Resources