Is there a way to use Google Analytics tag on Hub to track a link that leads to a offsite page.

631
0
05-28-2020 01:50 PM
JessicaSchneider
New Contributor III

I would like to see if the links we provide on our ArcGIS Hub site are being used.  I have a google tag on the hub app and i can see traffic to the site etc from google analytics but I can't see if a user clicks on a link that leads away from the stie. From what I gather I need to insert the following code to do this but not sure where I would do that using Hub.

<script>
/**
* Function that captures 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 captureOutboundLink = function(url) {
   ga('send', 'event', 'outbound', 'click', url, {
     'transport': 'beacon',
     'hitCallback': function(){document.location = url;}
   });
}
</script>

0 Kudos
0 Replies