We are using Google Analytics on hundreds of client sites. Each site has its own account, and we also have an account for aggregate data. We're using the following code for tracking pageviews to both accounts.
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345678-1']); //obviously fake UA numbers
_gaq.push(['_trackPageview']);
_gaq.push(
['aggregate._setAccount', 'UA-87654321-1'],
['aggregate._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);
})();
</script>
This is working well for tracking visits & behaviour, but I'm not sure how to implement the same type of double tracking for the ecommerce tracking code. We're using the usual _addTrans, _addItem and _trackTrans setup.
How can I adapt the ecommerce tracking to report to both accounts?
In your code, the aggregate. in the _gaq.push calls like aggregate._setAccount is used to create an additional named tracker.
Just copy the ecommerce _gaq.push code lines, and add aggregate. in front of the _addTrans, _addItem and _trackTrans calls.
For example,
_gaq.push(['_addTrans', ...parameters...]);
_gaq.push(['aggregate._addTrans', ...parameters...]);
Related
I tried to look for a good solution but couldn't find any.
I try to link multiple Google webmaster tools accounts to a single Analytics property.
I tried creating multiple views, but it seems you can't link it to a view.
I found a solution to add multiple domains to a Google Analytics property, but this seems outdated since Universal tracking
Note: probably some people might say I should 301 redirect the domains for duplicate content. But they are regionaly implemented using the hreflang alternate method which should be just fine.
You can link multiple Google Analytics accounts.
<script type="text/javascript">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_trackPageview']);
// Second tracker
_gaq.push(['secondTracker._setAccount','UA-YYYYYYYY-Y']);
_gaq.push(['secondTracker._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);
})();
</script>
See: http://seo-website-designer.com/Google-Analytics-Tracking-Multiple-Accounts
I'm trying to exploit the content grouping feature provided by Google Analytics for a blog hosted by Google Blogger.
The blog has been correctly set to be monitored by using Google Analytics (GA). GA provides 3 ways of grouping but in my case only the grouping by tracking code option seems to be the correct one. As far as I can see inspecting a blog page, by putting into the template the GA include
<b:include data='blog' name='google-analytics'/>
I correctly get the following JavaScript ga.js snippet into the page
<script type='text/javascript'>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'XXXXXXXXXXX']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = (document.location.protocol == 'https:' ?
'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
The problem is that I've no way to add the required call to set the group as required.
_gaq.push(['_setAccount', 'UA-40265412-2']);
_gaq.push(['_setPageGroup', 1, 'My Group Name']);
_gaq.push(['_trackPageview']);
Any idea in which way this can be implemented?
Thanks in advance
I am setting up a Javascript timer to grab the time-on-site for one page only with the following event tracking code:
(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);
})();
When I check the Network tab, there are outgoing pings to GA but in GA, there are no reports.
Any help would be greatly appreciated!
Google Analytics code in a web page usually consists of two parts:
Code to load the ga.js analytics code from google-analytics.com
Code to set the analytics account and specify what to track.
The code you've shown is only the first part which loads ga.js. You're missing the code telling Google Analytics what to do/track -- something like
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
It turned out that I needed to simply wait a duration of time before the event tracking turns on. Apparently, with GA, the time is quite variable.
I have a webshop where users come from many different other sites and newsletters. To track where the people came from, we use campaigns in Google Analytics.
Now we are implementing our own external payment site.
After a user places an order, they will be redirected to our payment site. After a succesfull payment, they should be redirected back to the original site. On the original site the ecommerce values will be fired into Google Analytics.
When I do this like I described above, I lost the campaign when insterting the ecommerce data. How do I make sure this information isn't lost?
[edit]
I found adding 'utm_nooverride' should to the trick. However, I can't find it clearly in the Google Analytics documentation
To solve the above:
On both sites (yes, the payment site should have a GA too), you need to set _setAllowLinker to true, and the _setDomainName to 'none'.
IE:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-YY']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_setDomainName', 'none']);
(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);
})();
</script>
I'm setting up google analytis on my webpage using the standard script:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_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);
})();
</script>
If I include this site on my UAT page (e.g. http://uatsite.com/) will google track any activity or will it only track activity on my main site (e.g. http://production-site.com).
thxs
The domain (or, as GA likes to call it, hostname) from which Google Analytics receives its info doesn't matter and really it's up to the client to define it (and is very much exploited, see this for just one example).
If you don't want to track activity on your UAT site, you can create a Hostname filter to prevent the data from being recorded. This filter can be of include type so that only your production site registers or exclude type so it excludes only your UAT site.
Alternatively, you can modify your analytics code to not track on the UAT site:
if (!/uatsite/.test(window.location.hostname)) _gaq.push(['_trackPageview']);
This will only collect analytics for the url you configured. This will not collect from any other domain.