Solved

JQuery tracking event.

Posted on 2016-10-20
3
55 Views
Last Modified: 2016-10-20
We are trying to track an event, each time somebody clicks a certain link on our site.  The problem is i just cannot get it to fire.  

We are using the following script :

<script type="text/javascript">
  	jQuery('#multiview').on('click', function() { 
	  	window._pq = window._pq || [];
   	 _pq.push(['track','AppBegin']);
  	});
</script>

Open in new window


The link is attached to an Image button in our footer
<a href="https://intelliapp2.driverapponline.com/c/hunt" target="_blank" onclick="ga('send', 'event', 'Apply', 'Click', 'apply-now-link', 1);" id="multiview"><img src="https://hunttransportationjobs.com/wp-content/uploads/2015/02/ButtonHunt.png" width="200" height="100" border="0" /></a>

Open in new window


Our website is https://hunttransportationjobs.com   and the image is the CLICK HERE - Apply Now Image link in the footer.  

Could some of you JQuery peeps have a look at the code, see if you can help me with this?
0
Comment
Question by:jonathan1978
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 41852666
Are you sure it is not firing - or are you just not getting the data.

Firstly the code you posted is commented out in the source - it appears you have changed to using classes - although I don't think that is the problem - just noting.

Secondly, have you tried putting console.log() statements in the code to see if it is firing.
Put one after the onclick
<a href="https://intelliapp2.driverapponline.com/c/hunt" target="_blank" onclick="ga('send', 'event', 'Apply', 'Click', 'apply-now-link', 1); console.log('On Click Fired')" id="multiview"><img src="https://hunttransportationjobs.com/wp-content/uploads/2015/02/ButtonHunt.png" width="200" height="100" border="0" /></a>

Open in new window

And one in your jQuery
<script type="text/javascript">
	$(document).ready(function() {
		window._pq = window._pq || [];
console.log('Document ready fired - setting one() click');
	$('.multiview').one('click', function() {
console.log('one() fired');
    	_pq.push(["track", "AppBegin"]);
  		}); 
  	});
</script>

Open in new window


Check the console after clicking on the link to see what messages are output.
0
 

Author Closing Comment

by:jonathan1978
ID: 41852720
Excellent thank you.   Yes I forgot i had posted the code in the question,  and was testing a little.  I get one() fired. So all works.
0
 
LVL 52

Expert Comment

by:Julian Hansen
ID: 41852841
You are welcome.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now