How to track UTM data in Squarespace form submissions

后端 未结 2 1516
盖世英雄少女心
盖世英雄少女心 2021-01-27 00:38

I\'ve seen a lot of questions about the easiest way to change the value of a parameter, but nothing about how to change the parameter itself.

For example:

exampl

2条回答
  •  我在风中等你
    2021-01-27 00:56

    The code you provided gets the link(href) of the anchor that has mylink class. With the link you replace the first occurrence of 'utm_' with 'sqf_'. Then you replace the link(href) of the anchor with the new link.

    To achieve change all occurrences of 'utm_' I used a regular expression /utm_/g.

    I added a snippet to clarify:

    $(document).ready(function(){
        // Gets current href of element with class mylink
        var url = $('.mylink').attr('href')
        // Replace all occurences of utm_ with sqf_
        url = url.replace(/utm_/g, 'sqf_')
        // Replaces the old href with the new one on the anchor
        $('.mylink').attr('href', url)
    });
    
    Link

提交回复
热议问题