0

I have a landing page with several products, with their own url per product. I want to transfer the tracking from the landing URL to the products URL, so I'm using this script:

    <script>
      var params = $.param(getUrlVars());
      $("a").attr('href', function(i, h) {
         return h + (h.indexOf('?') != -1 ? "&" + params : "?" + params);
      });
    </script>

It's working as expected, so from the URL

https://test.landing.com/?affiliate=XXX&utm_source=landing&utm_medium=test&utm_campaign=landing-test&utm_content=afiliate-test

I get the product URL

https://test.landing.com/product-test/?&utm_source=landing&utm_medium=test&utm_campaign=landing-test&utm_content=afiliate-test

I want to add to the parameter "affiliate=XXX"

Can please someone tell me how can I do it?

Dharman
  • 26,923
  • 21
  • 73
  • 125
  • You may see this https://stackoverflow.com/questions/5999118/how-can-i-add-or-update-a-query-string-parameter – Jerson Dec 29 '21 at 12:06

0 Answers0