How can I add a UTM tag with PHP code to pick up the post slug dynamically in the UTM?
The thing I want to do is doable, but I don't know how to do it.
Embarrassment moment coming up: I actually did this a few years ago but lost the code and can't find online how it's done.
What I want to do is to add a dynamic UTM tag on a link in my header so that the UTM tag picks up the slug of the page the visitor is clicking from.
Example: If the visitor is on a post with the slug /something-goes-here/ and clicks on the CTA button, the CTA page that he goes to should have /second-page/?utm_source=something-goes-here
Do you guys know how this can be done with a bit of code in PHP?
Topic google-analytics php Wordpress
Category Web