Google Analytics Event Tracking Not Working?


#1

Hi i installed event tracking on my site: http://www.mycareerstar.net/resume-sa…

Simply as a test i want to track when someone clicks on IT Executive

I used the following code:

IT Executive

Is the issue due to the fact that my domain http://www.mycareerstar.com is different to the actualy domain its currently on which is http://www.mycareerstar.net ?

Thanks,
Mark


#2

Hi Chris,

I see in your page that you have Google’s Universal Analytics installed. However, if you are trying to track a certain click-event on your Unbounce page, you’ll need to use Google Analytic’s jquery method to tie the action to your button.

To use this method, you would need your button ID (e.g. #lp-pom-button-16) to replace the #button in their example, like this:

ga('send', 'event', 'button', 'click', 'nav-buttons');  
}); ```   
 
Add that to your Unbounce page using [javascripts tool](http://support.unbounce.com/entries/513757-Can-I-use-custom-JavaScript-or-CSS-on-my-page-) and of course, you'll also want to update event, button click etc. to match your own reporting.

#3

for some reason i cant get this work for me. ive installed this snippet of code and it wont populate any data in GA (ive checked real time and todays stats). any ideas?


#4

Hi imjss - How long ago did you implement the code? From the time you added the script it can take up to 48 hours before the results show up on GA.

If it has been more than that I recommend starting a support ticket. We would be happy to dig in.


#5

Install the Chrome extension Google Analytics Debugger and then you can open the Javascript Console or Developer tools and SEE IN REAL TIME if your Google Event tracking code fired. You no longer need to “wait” to see your data in Google Analytics reports.

The other great thing is that you see Javascript errors, when you look at the console. Often you will see an error related to the GA scripts and it will be obvious what the problem is.

As for the GA tracking question you asked and why it isn’t working, did you also remember to include the Jquery library, on the page, BEFORE any Jquery code?

If you see $ not defined errors, that is a certain sign that the library didn’t load before the web page tried to use it.

Kim K


#6

Great tips Kim - thanks!


#7

When I use this method, I get an error on the page:

$(…).on is not a function

  • for -

$(’#lp-pom-button-47’).on(‘click’, function() {

I saw on another post where someone said that “on” doesn’t work in jQuery 1.4.2 - so then what?

Thanks for any help! I’m beating my head against the wall trying to get this figured out!


#8

Hey James - sorry for the delay on this! It should work with jQuery 1.4.2. That said, our resident jQuery expert says that in the scripts panel you should be able to uncheck the included jQuery on the left panel of the script window and include the version you want by adding the following script in the JS button area:

You’ll want to make sure that the placement is set to “Head”. You can change 1.8.3 to whatever version of jQuery is required. Hope that helps!


#9

Hey Lou,
In your post, I think you meant to include the code for me to put in there, but I don’t see it.

Can you get me that code to include the other version of jQuery that should work with the Event tracking in Google Analytics?

Thanks!
JH


#10

Hi James - I believe this was the code Lou was talking about:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>


#11

Ok, thank you!

I’m not clear on on thing:
Do I also have to add the Google Analytics tracking code in the Head of each page?

Seems like I’d have to, otherwise GA won’t know what account to send that data to.


#12

Correct James! The script provided is simply updating jQuery code to a version much more compatible with Universal Analytics.


#13

This is a very elementary question compared to the conversation that’s already taken place, but that’s where I am, so here goes:

I have all my Google event tracking ready, but I need to know where to direct the code be inserted on the page - before body end tag, after body tag or in the head.

Also, do I need to create a new script for each event or enter them all in one?

Thanks!


#14

Hey Christine - don’t worry, all questions are good questions!

You’ll want to place your Google Analytics Tracking Code in the Head of your landing page’s JavaScript library.

If you’re also using Google Event Tracking, it will go in the Head too (just make sure you separate them in the JavaScript library with the Add New Script button). Hope that helps!


#15

I am still beating my head against the wall with this issue. Would someone be so kind as to take a look and tell me what I’m missing here??

URL: http://try.weathercall.net/event-goal…

I’ve got 3 Javascript entries:

  1. jQuery

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

  1. Universal Analytics code (with domain set to ‘none’ since that’s the only way I could see myself even hitting the Unbounce page in Real-time GA):
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ <br />
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), <br />
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) <br />
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); <br /><br />
ga('create', 'UA-44193051-1', 'none'); <br />
ga('send', 'pageview'); <br /> </script>```   
 
3) Event code for the button:   
```<script> <br /> $('#lp-pom-button-47').on('click', function() {
<br /> ga('send', 'event', 'button', 'signup', 'trial');
<br /> }); <br /> </script>```   
 
When I watch the console and set it to persist, I don't see the Event trying to fire at all, and I don't see any errors about $ being undefined or anything.  
 
I'm stumped and I've GOT to get this working so we can tell which Ad groups are converting and which aren't.   
 
At least I see myself hitting the page now in Analytics, so I feel like I'm close... but I have no idea why I don't see the event try to fire when I am _pretty_ sure I followed all of these instructions to the letter.  
 
Any help would be **greatly** appreciated!   
 
JH

#16

Hey James - I reviewed your page just now and it looks like everything is in the right place. Do keep in mind that it can take up to 48 hours before the tracking initially kicks in. On occasion I have seen real-time tracking fail to trigger, but eventually feed through to the actual events reporting.

Since this is Universal Analytics, I do have to caution we can’t guarantee how functional it’s features may be with Unbounce as it’s still in ‘Beta’. While some customers have had some success, others have encountered issues.

If it’s essential for you to get your event tracking working I highly recommend using ‘Classic’ Analytics. We can vouch for its event tracking abilities. If your interested in taking this route, you can use the following script below to trigger the event:

  _gaq.push(['_trackEvent', 'button', 'signup', 'trial']); <br /><br /> }); <br /> </script>```

#17

Just thought I would add that another option for event tracking (the one I use) with Unbounce pages is Google Tag Manager. GTM has event tracking functionality now. Check Justin Cutroni’s post about it.

To test if it’s working, use the tag manager assistant extension, make sure you’re not in a profile filtering out your visits, and look at the event in real time analytics.

Super simple. As long as you have decent command of regex and get comfy with GTM, it should only take a minute or so to set up events.

I’ve tried pretty much every approach to event tracking and I’m liking the new GTM approach a lot, particularly for Unbounce. Kinda skeptical about GTM in general but… specifically for event tracking on Unbounce pages, it’s great.


#18

I didn’t even think about using GTM - that’s a great idea. Thanks Reuben, will give that a shot!


#19

No problem! (should probably mention I’m not Reuben, just part of his team and logged into his account…)

Also, since the question has touched on concerns around cross-domain tracking and UA vs traditional analytics, GTM has some nice solutions for that as well. I think (?) lunametrics posted a walkthrough for that recently for anyone interested, though I’m sure there are plenty out there. Lots of nice documentation/experimentation is showing up right now for GTM.


#20

Hey everyone!

We put together a couple of support articles on our recommended setup for Event tracking with Universal Analytics. You shouldn’t have any trouble with it as we’ve worked around the problems that were causing the methods above to fail. Check them out:

Button Events
http://support.unbounce.com/entries/2…

Form Submission Event
http://support.unbounce.com/entries/2…