Google analytics event tracking inconsistent - google-analytics

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.

Related

Google Analytics - add third party shopping cart to main domain reports

We would like to track if users sent from our main site to a third party site have bounced or clicked on "Register"
They are willing to put our Analytics code in their pages - both product and registration.
I looked at what is suggested by Google but not clear about a few things.
Our current code on our site:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-nnnnn-1']);
_gaq.push(['_setDomainName', 'none']);
_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>
Code suggested by Google to be on the third party site:
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345-1']);
_gaq.push(['_setDomainName', 'my-example-blogsite.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
</script>
...
<a href="http://dogs.example-petstore.com/intro.html"
onclick="_gaq.push(['_link', 'http://dogs.example-petstore.com/intro.html']); return false;">
See my pet store</a>
Our code has 'none' in this line: _gaq.push(['_setDomainName', 'none']);
Google's sample code has the URL
_gaq.push(['_setDomainName', 'my-example-blogsite.com']);
Does it matter? Do I need to enter the domain as suggested?
Also Google's code has a link back to our site as follows
onclick="_gaq.push(['_link', 'http://dogs.example-petstore.com/intro.html']); return false;"
Do we need to have a link back? Can we remove the onclick code or will it affect the reporting?
Thanks!
Myalo
You need the onclick event. What is does is to "decorate" the link, i.e. it adds the url parameters that need to be carried over to the other domain (where they are picked up by the Google code and used to continue the session).
Please be aware that the code you are using is horribly outdated. If at all possible switch to the current version (Universal Analytics). While cross domain tracking on Universal Analytics works by the same principle it'S somewhat more elegant (uses a single parameter as opposed to the unwieldy query string for classic GA) and offers a number of helper functions to make cross domain tracking easier.

Event Tracking Not Showing up in Reports

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.

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 reports to be receiving data, but none is showing up

Hi recently redesigned my site (http://bit.ly/gwrYwb) which was formerly tracking pageviews properly via Google Analytics. After the redesign, I inserted the exact same code right before the </head> tag:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-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>
(The UA number is correct on the actual page.) However, GA is mysteriously reporting zero pageviews/visits, even though it claims to be receiving data. Has anyone experienced a problem like this before? The only other JS I'm using is including jQuery, as well as a widely-used jQuery plugin on one of my pages.
This is kind of lame, but have you checked your profile filters? You might still have old filters (for the former website) applied that filter all urls out.
We had this problem with another website and were debugging for weeks until we found this simple solution...

Google Analytics: Page views tracked but not ecommerce transactions

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!

Resources