Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SOLVED Outgoing links analytics?
#2
Turns out with a little trickery it can be done.

https://support.google.com/analytics/ans...6920?hl=en

My adapted version:
<script>
/**
* Source: https://support.google.com/analytics/ans...6920?hl=en
* Function that tracks a click on an outbound link in Analytics.
* This function takes a valid URL string as an argument, and uses that URL string
* as the event label. Setting the transport method to 'beacon' lets the hit be sent
* using 'navigator.sendBeacon' in browser that support it.
*/
var trackOutboundLink = function(event) {
var url = $(event.target).attr("href");
//Check if this is an out-bound link, and GA has been instantiated
if(typeof ga != "undefined" && !(url.startsWith("/") || url.indexOf("domain.com") > -1))
ga('send', 'event', 'outbound', 'click', url, {
'transport': 'beacon',
'hitCallback': function(){document.location = url;}
});
}
//Once the DOM has loaded, attach a click handler to all the available links
$("body a").on("click", trackOutboundLink );
</script>
Reply


Messages In This Thread
Outgoing links analytics? - by Tsaukpaetra - 2016-10-25, 14:59:39
RE: Outgoing links analytics? - by Tsaukpaetra - 2016-11-27, 13:17:24



Users browsing this thread: 1 Guest(s)