Streaming live at 10am (PST)

Show external link url in 'value' setting for google analytics link tracking

Hey there,
I’ve been wrestling with this one and I’m having a bit of an issue. I’ve finally linked up google analytics so that the ‘onClick’ trigger (replaced by a ga-track line) shows the interaction, but I’m looking to show the URL of an outbound link within that interaction on GA.

The initial solution to get the event to show was found here:

which was extremely helpful. The code shows certain perimeters that look like the could be altered to call for the link’s url, but I’ve had no luck.

The reason I’m doing this is because I have a series of randomized ads that need to be tracked when the ‘visit our sponsors’ button is clicked. They’re set up via the CMS, so the address is different depending on which ad pops up.

Any help in figuring out how to display the URL in the Event Catagory section of GA would amazing.

I’m not very code savvy, I can somewhat understand what I’m looking at but have had no luck in bashing with other code that would display the URL.


Here is my public share link: LINK
(how to access public share link)

Please add your shareable link here so we can see what you are referring to? TIA

Will do. Thanks for the quick reply!
It’s the ‘Visit our Sponsors’ button. currently I’ve only attached the tracking to the top right hand button.

1 Like

Thanks @Neilsonbird, dont forget to share a link to your project too.

Didn’t realize that was an option, sorry. Link as follows

Check out the missing data as well. You have the info there, but are missing the the data to track the link. Thats where you would setup your tracking UTM within GA and add that to your value attribute on the button itself. I think!

Sorry I’m not familiar with what UTM is if that covers the following.
Looking at the code (this is the only one that I was able to get to work), the person in the link had set this up so that those values are basically plain text that gets pushed to GA- they’re not actually representing anything within the code. Me calling them “trackOutboundLink, Type, etc” are just fillers. I’m not sure if there’s some code that I could put in the value, or on the back end, that would replace a parameter with the buttons’ URL.

The driving code to push those values is this:

(document).ready(function() { (document).on(‘click’, ‘[data-gatrack]’, function(e) {

    var $link = $(this);
            var commaSeperatedEventData = $'gatrack');
            var eventParams = commaSeperatedEventData.split(',');

            if (!eventParams) { return; }

            eventCategory = eventParams[0]
            eventAction = eventParams[1]
            eventValue = eventParams[2]

            ga('send', {
                           hitType: 'event',
                           eventCategory: eventCategory,
                           eventAction: eventAction,
                           eventLabel: eventValue

I think I need to augment that code to call for the links URL but I’m not sure… maybe I’m way off.

1 Like

@Neilsonbird, you can try the info in this article:

Also, when I look at your code for the Attributes you do have some values, but are missing the tracking links for GA. UTM is ( Urchin Tracking Module), refer to this wiki:

My suggestion is to use Google Tag Manager, which would create those parameters for you. Thats the top link.

Here is another link:

I would follow the info here. Its pretty self-explanatory. The Google Support one might be a better bet.

Thank you, I’ll dig into that. And thanks very much for taking the time to help! I’m more a shapes and colors kind of guy so I’m a bit in over my head with this one.

1 Like