Link to home
Start Free TrialLog in
Avatar of Lanmarkian
Lanmarkian

asked on

Event Tracking Not Working

I have a drop down menu, when a user clicks on an item in a drop down menu, it links them to a page.

Here is my code. The event tracking is not displaying in my google analytics. Am I doing something wrong?

<option onclick="_gaq.push(['_trackEvent', 'LocationsPage', 'Link', 'Fair Oaks']);"  value="http://www.themaxchallenge.com/locations/fair-oaks-ca/">Fair Oaks, CA Center</option>

Open in new window


URL: http://www.themaxchallenge.com/max-challenge-promo-max100/
Avatar of Gary
Gary
Flag of Ireland image

I cannot see anywhere that you are including the analytics js code.
Avatar of Lanmarkian
Lanmarkian

ASKER

It's in there. If you view the source it's line 128.
Add this to your script
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-34340861-1']);
  _gaq.push(['_trackPageview']);

Open in new window

Here is the original:

<script>
			(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
			(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
			m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
			})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

			ga('create', 'UA-34340861-1');
			ga('send', 'pageview');
			</script>

Open in new window


Adding that would make it:
<script>
			(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
			(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
			m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
			})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

			ga('create', 'UA-34340861-1');
			ga('send', 'pageview');
 var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-34340861-1']);
  _gaq.push(['_trackPageview']);
			</script>

Open in new window


Am I allowed to have the UA-xxxxx in there multiple times? Is that correct what I have?

Thanks for the help.
You have to create the object before you can push data into it and hence to GA.
You don't have it set anywhere else that I can see ergo the error when you try and push data

You don't need this as well as we are now creating the array.
ga('create', 'UA-34340861-1');
ga('send', 'pageview');
Sorry, I am a little confused. Can you paste the code in exactly how I need it? I appreciate your help.
<script>
	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', 'UA-34340861-1']);
	_gaq.push(['_trackPageview']);
	(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
	(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
	m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
	})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
</script> 

Open in new window

Thanks. I went ahead and placed that in, but I am still not seeing the events being tracked. Am I missing anything at all??
What is the point of this/what are you trying to do? (it occurs twice inline in your page)

$('#dropDown').change(function(){
$(this).find("option").each(function()
{
$('#' + this.value).hide();
});
$('#' + this.value).show();
});

It causes a js error breaking everything else
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok, I tried this out again. Wish me luck...