Google Analytics: Page views tracked but not ecommerce transactions - google-analytics

I'm trying to figure out why the Ecommerce tracking in Google Analytics doesn't seem to work. I can see the page views correctly tracked but no transactions.
Snippet from the confirmation page:
<head>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-1']);
_gaq.push(['_setDomainName', '.mydomain.com']);
_gaq.push(['_trackPageview']);
_gaq.push(['b._setAccount', 'UA-YYYYYYYY-1']);
_gaq.push(['b._setDomainName', 'none']);
_gaq.push(['b._addTrans',
'44bbd391-ff38-4f8d-ad68-aec490666151',
'Name',
'1.00',
'',
'',
'',
'',
''
]);
_gaq.push(['b._addItem',
'44bbd391-ff38-4f8d-ad68-aec490666151',
'15',
'test',
'',
'1.00',
'1'
]);
_gaq.push(['b._trackTrans']);
_gaq.push(['b._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>
...
</head>
I'm monitoring the traffic on the page with Firebug confirming that all pixel requests were made and came back OK.
I read about having to wait a few hours, up to one day, before you can see results in GA, but I can see the page views after only waiting a few minutes.
However, the transactions tracked using the same tracker object ("b") are not to be found anywhere(could the Ecommerce reports be refreshing slower than the page views?)

And I finally found the issue. The answer is inconspicuously present on the GA docs page:
_trackTrans()
Sends both the transaction and item
data to the Google Analytics server.
This method should be called after
_trackPageview(), and used in conjunction with the _addItem() and
addTrans() methods.
It's rather easy to overlook but it has such a fundamental effect: transactions won't be tracked.
So yes, always call _trackTrans after _trackPageview!

Related

Google analytics event tracking inconsistent

We have implemented GA for tracking clicks as a button and registering them as conversions so we can track them. Our GA include looks like this:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_setDomainName', 'XXXXXXXX.com']);
_gaq.push(['_setAllowLinker', true]);
_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>
Our code to trigger the event looks like this:
<input type="submit" name="" value="Contact" onClick="_gaq.push(['_trackEvent', 'Property', 'Click', 'Inquiry']);" />
We have the code tracking, but it seems to only pick up a fraction of the conversions. It does record conversions but it doesn't seem to get them all. For instance a couple days ago, we had 17 conversions (we can verify by copies of email) but GA only recorded 1. The site runs always on SSL if that matters.
Can anybody see any obvious reasons as to why we're not tracking all conversions? Thank you!
Google Analytics submits data as parameters on an image request -- the problem is that browsers will cancel pending image requests when navigating to a new page, and it's hit or miss whether the image request gets out before being canceled.
The most common solution involves adding a slight delay (150ms seems to work) after the _trackEvent and before the actual form submit.

Grouping Blogger posts for blogs monitored via Google Analytics

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

Google Analytics Ecommerce Tracking - Multiple Accounts

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...]);

Google Analytics Campaign tracking with external payment site

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>

Google Analytics custom events not tracking properly

Here's the GA output code:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA_CODE']);
_gaq.push(['_setDomainName', 'SUBDOMAIN']);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackEvent', 'Priority', 'Created (day)', 'Label info', '']);
(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>
the trackEvent line seems to be correct...but not tracking for some reason. Is it because I left the value field nil?
For _trackEvent, the value parameter should be an integer. Since it's an optional parameter, you can just leave it out:
_gaq.push(['_trackEvent', 'Priority', 'Created (day)', 'Label info']);
Having a non-integer value will prevent the event from being tracked.
I beleive _trackEvent won't work properly when called from GA tracking code snippet, at least it was not made for such usage. If you want to execute an event after page loads, try calling it for example from onLoad event of your body tag.
Secondly, passing an optional value parametr as '' would make it undefiened, which looks like it could produce an error, so, since it's optional, don't pass it at all.
And there's a delay in GA reportings, data processing takes about 24 hours (you can switch between new and old versions, sometimes one shows data faster than another).

Resources