Solved

JQuery tracking event.

Posted on 2016-10-20
3
78 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 55

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 55

Expert Comment

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

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

808 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