Analytics
1.8K members online now
1.8K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

Track clicks for select set of links from homepage

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

We like many people have a number of graphics/links on our homepage. Most of those links are static and point to navigation, about us, etc. Some of the links are promotionally related and changed every week or two.

 

We are currently manually tracking analytics on the promo related links which is time consuming and error prone. Our goal would be to somehow segment these promo links and be able to group them together to analyze.

 

I originally thought that using Campaign Parameters would be a good way (just tag the links), but then realized that using Campaign Parameters would override true incoming Referral data.

 

Is there something like a Campaign Parameter that can be appended to a link? Or another option that can easily be administered when new links/graphics are added?

 

Thanks,

Dave

1 Expert replyverified_user

Re: Track clicks for select set of links from homepage

Top Contributor
# 2
Top Contributor
Hi Dave,

Have you considered using Google Tag Manager? If all of these promo links/graphics are set up the same way, you could look at creating an event by an element type:
https://support.google.com/tagmanager/answer/6106716?hl=en#AllClicks

And even if that wouldn't work because you're using links (<a> element) at least it's quicker to implement and can be done without a developer:

https://support.google.com/tagmanager/answer/6106716?hl=en#ClicksOnLinks

Let me know if you have any other questions!
JD

Re: Track clicks for select set of links from homepage

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Thanks JD.

Based on your advice, I've spent some time trying to set up a GA click event through GTM. Unfortunately the documentation G has for GTM does not match the actual GTM parameters (I would guess they have made some changes and not updated their documentation). Since I am not a GTM expert, I don't think I am doing it the right way. Do you have any advice on how to set this up properly without accurate documentation its going to be hard.

Dave

Re: Track clicks for select set of links from homepage

[ Edited ]
Explorer ✭ ✭ ☆
# 4
Explorer ✭ ✭ ☆

Hi David,

If you could paste some of the links (as they appear in your site's code) that you want to measure in one category then I'd try to prepare a simple guide how to set it up. Optionally you could tell me what element would be the same for all the links in given category.

Re: Track clicks for select set of links from homepage

[ Edited ]
Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

That is very kind of you, thank you.

At this point the links typically go to product and or category pages from our home page (http://www.pssl.com). They are simple links that come from hero or promo graphics. Links might look like this http://www.pssl.com/JBL-EON-ONE-All-in-One-Linear-Array-PA-System

We don't have a common element, but could add one that GA or GTM could track. We just don't want to disrupt SEO view of the links. Not sure if that makes sense.

Re: Track clicks for select set of links from homepage

[ Edited ]
Explorer ✭ ✭ ☆
# 6
Explorer ✭ ✭ ☆

Hi David,

You may try doing like this, however I don't guarantee it will work - usually I'd need to do some testing with GTM debugger to see it works as expected:

1. Enable all "Click" variables in GTM (just check each one of them) - tab "Variables", also enable "Event" variable in "Variables->Utilities"
2. Create variable of Custom Java Script type named e.g. "JS - get URL alt" that will extract "alt" attribute's text (to identify a promo link):

var getElementText = function(el) {
var text = '';
if ( (el.nodeType === 3) || (el.nodeType === 4) ) {
text = el.nodeValue;
} else if ( (el.nodeType === 1) && (
(el.tagName.toLowerCase() == 'img') ||
(el.tagName.toLowerCase() == 'area') ||
((el.tagName.toLowerCase() == 'input') && el.getAttribute('type') && (el.getAttribute('type').toLowerCase() == 'image'))
) ) {
text = el.getAttribute('alt') || '';
} else if ( (el.nodeType === 1) && !el.tagName.match(/^(script|style)$/i) ) {
var children = el.childNodes;
for (var i = 0, l = children.length; i < l; i++) {
text += getElementText(children[i]);
}
}
return text;
};

 

2.1. Alternatively if saving the link's URL would be enough for you then you can omit creating this variable and use built-in variable "Click URL" that will contain URL of clicked link.


3. Create Google Analytics tag. You can set whatever you want in Category, Action, Label but we'll need one field to pass "alt" information from clicked link e.g.
Category: Promo link clicked
Action: {{JS - get URL alt}} 
Label: undefined


Set "Non-Interaction" to 'False'

 

3.1 If you decided to go with 2.1 instead of 2.0 you should configure tag like this:

 

Category: Promo link clicked
Action: {{Click URL}} 
Label: undefined


Set "Non-Interaction" to 'False'

 

4. Add a trigger to that tag:
Custom Event type
Event name: gtm.click
Add filters
Click Classes equals shopnow

5. Save tag, preview and test if the tag is fired when you click on "Shop now" button on your homepage's promo buttons. Also check if variable {{JS - get URL alt}} (or "Click URL") is getting populated with text from "alt" attribute of clicked promo picture.

If it works then anytime anyone clicks on a link you get an Event in Analytics with link's alternative text in it. It will work for any promo product for as long as class in promo links would remain "shopnow"

If you decide to test it please let me know - if it's not working (especially JavaScript part) I'll try to help.

Re: Track clicks for select set of links from homepage

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭
Wow, thank you for all your time on this. I tried the above and got this error.

JavaScript Compiler Error JS - get URL alt
Error at line 2, character 4: Parse error. primary expression expected

Re: Track clicks for select set of links from homepage

Explorer ✭ ✭ ☆
# 8
Explorer ✭ ✭ ☆
Hi David,

Like I said, JavaScript is not my strongest suit. So maybe try approach
with {{Click URL}} instead and see if it works as expected. If it does then
you have a working solution and in the meantime we may focus on improving
JS script to use it later instead of {{Click URL}}.

Please let me know if it worked.