网站在现场链接中复制查询字符串参数

时间:2014-06-12 22:16:03

标签: javascript

使用Google网址跟踪代码时,IsaFYI.com存在问题。

例如,如果有人访问该页面:http://isafyi.com/mom-of-two-covers-college-expenses-with-isagenix-business/then点击故事底部的识别链接,则会将其转到页面http://isafyi.com/category/recognition/。如果有人点击销售促销的链接,他们将被带到页面http://isafyi.com/sales-promotions/

However, if tracking code is placed on the first page, (in this case, ?utm_source=test&utm_medium=test&utm_campaign=test,) the first url looks like this:

http://isafyi.com/mom-of-two-covers-college-expenses-with-isagenix-business/?utm_source=test&utm_medium=test&utm_campaign=test

如果点击此链接,现在点击页面底部的识别链接,则会将其带到

http://isafyi.com/recognition/?utm_source=test&utm_medium=test&utm_campaign=test?utm_source=test&utm_medium=test&utm_campaign=test

If you look carefully, you can see that the tracking code is now on the link twice:

http://isafyi.com/recognition/
?utm_source=test&utm_medium=test&utm_campaign=test
?utm_source=test&utm_medium=test&utm_campaign=test

如果从这个页面开始点击销售促销链接,他们将被带到:

    http://isafyi.com/salespromotions/utm_source=test&utm_medium=test&utm_campaign=testutm_source=test&utm_medium=test&utm_campaigtestutm_source=test&utm_medium=test&utm_campaign=testutm_source=test&utm_medium=test&utm_campaign=test

双倍代码再次加倍。每次点击内部链接时,这会呈指数级增长。

如果用户现在点击指向外部站点的链接,则服务器会拒绝该链接。出现的消息是:

请求的网址已被拒绝。请咨询您的管理员。

您的支持ID是:XXXXXXXXXXXXXXXXXXXXX

1 个答案:

答案 0 :(得分:1)

你有一个javascript文件“isafy.js”。你有一段代码:

var curUrl = window.location.href; // Gets the url of the current page
    var qs = curUrl.slice(curUrl.indexOf('?utm_')); // Checks url for Google Analytics Query string and if it exists, it is stored in variable 'qs'

    // If 'qs' has 1 character or less it is cleared out
    if(qs.length <= 1){
        qs = ""
    }

    // Goes through every a link on the page and appends the Google query string to every link
    $('a').each(function() {
        var href = $(this).attr('href');
        href += qs;
        $(this).attr('href', href);
    });

此代码添加utm字符串,但不检查参数是否已被追加。因此,对于每个单击的链接,您将获得添加到URL的另一个参数实例(因此,Crayons注释是点击的。)

我甚至无法说出这是为了什么 - 对于Google Analytics来说,如果在着陆页上设置参数就足够了。如果您需要在页面中的其他位置使用utm值,则应考虑使用cookie,如果不删除此脚本。