Eric
Eric

Reputation: 11

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!

Upvotes: 1

Views: 216

Answers (1)

mike
mike

Reputation: 7177

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.

Upvotes: 1

Related Questions