Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

JQuery tracking event.

Posted on 2016-10-20
3
Medium Priority
?
110 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:Jon Imms
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 59

Accepted Solution

by:
Julian Hansen earned 2000 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:Jon Imms
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 59

Expert Comment

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

722 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