I am using Webflow to host blog content. I need a way to tag certain links within the posts, so that they can be tracked separately in Google Analytics.
Does anyone know how I can tag a link that is within rich text, ie) class=“affiliate”
I was trying to access the HTML source code in the editor and so I could add the class type in front of the link, but can’t see where I an do his either.
Use Google Tag Manager. You should be able to detect all link clicks, isolate them to links within your rich text, and get the text and URL of the link. That should allow you to tag and record the analytics for each link individually.
Use the rel option on your links to tag them specially, like tag-partner-link. it’s designed for a different purpose, but I suspect Google would just ignore unrecognized rels. You can then use custom code and GTM datalayer to capture specific link clicks directly. It’s some work but I use this technique a lot when I want very specific analytics.
In some cases I use rel and then have script pull that and move my special tags to custom attributes on that same link. This keeps it “clean” for Google and lets me do unique things like link-specific CSS styling and GTM tracking.
You can also use Embed fields within rich text which gives you full HTML control however you lose the benefit of the designer for that paragraph, and it’s inconvenient for non-technical editors.