Google Analytics; Track outbound clicks; How?
By : Aldrin Rimong
Date : March 29 2020, 07:55 AM
I hope this helps . Here's the problem: every item of data recorded & reported by Google Analytics is sent to the GA Servers in the Request URL component of a Request by the client for the __utm.gif. The function _.trackPageview() provokes the collection/concatenation of the data into a Request URL, as well as the Request itself. In other words, if _trackPageview() isn't called, no data is sent to the GA Servers. So the question is whether the GA Request (above) is processed before the Request associated with the outbound link. If it is not, then the click on the outbound link is not recorded by GA, which is not what you want. code :
<script type="text/javascript">
function fnx(that) {
try {
var pageTracker=_gat._getTracker("UA-YOURACCOUNTHERE-PROFILE");
pageTracker._trackPageview("http://www.outbound_link.com");
setTimeout('document.location = "' + that.href + '"', 100)
}catch(err){}
}
</script>
<a href="www.outbound_link.com" onclick='fnx(this);return false;'>"Take Me Here"</a>
|
How to execute a function and track outbound link on page exit using Javascript?
By : fzyldrm
Date : March 29 2020, 07:55 AM
help you fix your problem I want to execute few functions before the page just exits such as logging page exit time. code :
links = document.getElementsByTagName('a')
for(var i=0; i<links.length; i++){
links[i].addEventListener('click', function(event){
//do your stuff
return true;
});
};
this.href
|
How to track clicks on outbound links
By : Angela
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Here's what I'm using, which has been working for me. I'm using jQuery to add the onclick handler to any link with a class of "referral", but I'd expect adding it directly in the HTML to work as well. code :
$(function() {
$('.referral').click(function() {
_gaq.push(['_trackEvent', 'Referral', 'Click', this.href]);
setTimeout('document.location = "' + this.href + '"', 100);
return false;
});
});
|
JavaScript or PHP scripts to track image clicks and impressions
By : user3664137
Date : March 29 2020, 07:55 AM
may help you . create a php where you want you client side to send you the click and impression notification. (javascript is a whole name of language so if you say a php script, say a javascript script, just to help). code :
//onclick event handler
$('img').on('click',function(){
$.post('yourphpscript.php',{ path: $(this).attr('url'), event: "click" });
});
//onload event handler
$('img').on('load',function(){
$.post('yourphpscript.php',{ path: $(this).attr('url'), event: "load" });
});
|
Track clicks on different iframes with JavaScript
By : Intellective Jeton
Date : March 29 2020, 07:55 AM
seems to work fine I managed to get it working, this is the code I used to check fi any ancestor of the iframe contains a particular class and performing different actions based on that: code :
var monitor = setInterval(function() {
var elem = document.activeElement;
if(elem && elem.tagName == 'IFRAME'){
if (elem.closest('.class_one') !== null) {
alert('this iframe has a parent with class class_one');
}
else if (elem.closest('.class_two') !== null) {
alert('this iframe has a parent with class class_two');
}
else if (elem.closest('.class_three') !== null) {
alert('this iframe has a parent with class class_three');
}
clearInterval(monitor);
}
}, 500);
|