Streaming live at 10am (PST)

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


#1

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.

Thanks.


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


#2

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


#3

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.
https://www.durangotv.com/


#4

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


#5

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

https://preview.webflow.com/preview/durango-8375c5-d6f93476d5ab299375364126?utm_source=durango-8375c5-d6f93476d5ab299375364126&preview=b41f59d4fea9c73534ab8a0c71f37594


#6

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!


#7

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:

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

    var $link = $(this);
            var commaSeperatedEventData = $link.data('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
            });
      
  });
});
/script

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


#8

@Neilsonbird, you can try the info in this article: https://support.google.com/analytics/answer/1136920?hl=en

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: https://en.wikipedia.org/wiki/UTM_parameters

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

Here is another link: https://orbitingweb.com/blog/track-outgoing-link-clicks-gtm/

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


#9

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.