Universal Google Analytics - Can I use my usual analytic event tracking?


I was a little confused when reading how to utilize UA in Unbounce. Do I need all the code shown here: http://support.unbounce.com/entries/2… (center code chunk) in order to utilize Universal Analytics in Unbounce? I typically just have a second JS with all my analytics events… like this:

$(’#ga-info01’).on(‘click’, function() {
ga(‘send’, ‘event’, ‘Downloads’, ‘click’, ‘cost of email infographic’);

Can I not do it here the same way?


Hey Stephanie

That method didn’t play well for many of our customers. The problem was the page would redirect to the link before the event could ‘fire’. If your tracking elements on your page that aren’t links/redirect then your code may work just fine.

Our version of the script uses GA’s callback feature to ensure that the event reaches Google before redirecting the page.

Here’s a example of what’s happening in our GA event script where it uses the callback fucction:

event.preventDefault(); <br />
var buttonLink = $(this).attr("href"); <br /><br />
if (typeof ga != 'function') {
<br />
  window.location = buttonLink; <br />
} <br /><br />
ga('send', 'event', 'button', 'click', 'label', { <br />
  'hitCallback' : function () { <br /><br />
   window.location = buttonLink; <br />
  } <br />
  }); <br /> }); <br /><br /> </script>```   
This is actually a older version of our current script. The one that we have now auto tracks all buttons on your page and is backwards compatible with 'classic' analytics.   
Hope that answers your question!


We’ve implemented a much easier way to implement Google Analytics and Event Tracking on your landing pages by using Script Manager. 

Check out the release here: 

Or check out the full step-by-step guide in our Academy here: