Skip Navigation

[Resolved] I need to be able to add an alt tag to a dynamic link

This thread is resolved. Here is a description of the problem and solution.

Problem:

I want to track clicks on members’ names (linked to their profile pages) using Google Tag Manager by referencing an alt tag, but I can’t add an alt tag to the clickable post title generated by [wpv-post-link].

Solution:

Replace [wpv-post-link] with a custom HTML anchor tag using [wpv-post-url] for the href and [wpv-post-title] for the link text. This allows adding any custom attribute (like alt or data- tags) that GTM can read:
[wpv-post-title]

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-url

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 reply, has 1 voice.

Last updated by brianC-15 6 days, 16 hours ago.

Assisted by: Christopher Amirian.

Author
Posts
#2829290

Tell us what you are trying to do?
My website is a directory and it is important that I can give data to those members on the number of times their image or the name (linked to their profile page) is clicked on. I use Google Tag Manager and I have set up the trigger to be linked to the 'alt tag' of the text link. I have successfully set this up for the image when clicked but I can't see how to add an alt tag to a post litle with link which is the field used for the clickabel link above the members profile image.

Is there any documentation that you are following?
Not that I can find

Is there a similar example that we can see?
Yes I do this on my other websites citytherapyrooms.co.uk on the home page you will see all the therapists images and below them is the name (linked) to their profile page and each name has an Alt Tag associated with the specific therapist and this triggers an 'event' in GTM

What is the link to your site?
hidden link

#2829294

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Welcome to Toolset support. You will need to use shortcodes and HTML code for that.

Replace [wpv-post-link] with a custom <a> so you can add attributes GTM can read:

<a href="[wpv-post-url]" alt="whatever you need to add here">[wpv-post-title]</a>

Make sure you use [wpv-post-url] for the HREF attribute of the anchor tag instead of [wpv-post-link].

Thanks.

#2829295

Thanks Christopher

I'll give that a go