Add current URL Slug to UTM

So - for my blog pages - I have a sidebar CTA that is the same on all blog pages - and it links to another page on my site. I want to take the URL of the blog page that someone is on when they click the link to add that pages URL slug as a UTM on the click.

So - they land on www.mysite.com/blog-page-1

then they click my CTA - and they go to www.mysite.com/registrationpage

but I want them to go to www/mysite.com/registrationpage?utm_source=blog-page-1


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

In general it is possible by JavaScript. To give you the exactly code someone should write this.

The code idea±:

  1. Get the current url of the button.
let base_url = $("#btn").attr("href");
  1. Get the extra value you wants to add (get the txt of h1 => page name).

  2. Set

// Change the URL of the button */
$("#btn").attr('href',`${base_url}?utm_source=${some_extra_value}`);