Tell us what you are trying to do? I'm trying to add google tracking tags to specific elements in my loop.
Is there any documentation that you are following? Nope. Couldn't find any.
Is there a similar example that we can see? See attached screenshots that show my existing loop, and a modification of the current HTML that shows what I'm trying to do.
What is the link to your site? hidden link
Hi Valerie,
Thank you for contacting us and I'd be happy to assist.
If your goal is to include "data-gtm-value" attribute to specific links in the view, you can replace:
<a href="[types field='link-to-yt' output='raw'][/types]" target="_blank" class="yt-play gtm-click-tracking" rel="noopener noreferrer">
With:
<a href="[types field='link-to-yt' output='raw'][/types]" target="_blank" class="yt-play gtm-click-tracking" rel="noopener noreferrer" data-gtm-value="[wpv-post-title output='sanitize']">
This will include "data-gtm-value" attribute with the sanitized post title as value.
( ref: https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-post-title )
For the post's slug as value, you can use the "wpv-post-slug" shortcode instead.
( ref: https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-post-slug )
<a href="[types field='link-to-yt' output='raw'][/types]" target="_blank" class="yt-play gtm-click-tracking" rel="noopener noreferrer" data-gtm-value="[wpv-post-slug]">
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
That solution worked in the first instance, but I can't get it to work in the second instance (in the button group). It's being filtered out, even extra hard-coded info such as, data-gtm-value="hardcodetest", is stripped.
The first instance it is a raw output within an
Thanks for the update and glad that it worked.
Your observation is correct and since the second instance is using the tag or link generated using the types shortcode, it will need to be generated manually too, like the first one:
<a class="button gtm-click-tracking" href="[types field='link-to-lesson-plan' output='raw'][/types]" title="Lesson Plan" target="_blank" data-gtm-value="[wpv-post-title output='sanitize']">
....
</a>
This should do the trick.
My issue is resolved now. Thank you!