Solved

JQuery tracking event.

Posted on 2016-10-20
3
41 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 51

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 51

Expert Comment

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
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 purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

746 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

12 Experts available now in Live!

Get 1:1 Help Now