创建一个具有查询参数的网址

时间:2021-02-28 11:24:29

I have a site which has disable the url rewriting. So I have a problem with query string parameters and I can't enable the gclid parameter for Adwords.

我有一个禁用网址重写的网站。所以我的查询字符串参数有问题,我无法为Adwords启用gclid参数。

Here is the problem. Ideally the url param should be something like this:

这是问题所在。理想情况下,网址参数应该是这样的:

http://www.example.com?gclid=test

but I take but this:

但我接受了这个:

http://www.example.com/gclid/test

As I static solution to make the url param work I used this:

作为我使用url param工作的静态解决方案,我使用了这个:

if (window.location.href === "http://www.example.com") { 
   url = "http://www.example.com?gclid=test"; 
   window.history.pushState("", "", url); 
}

Could be possible to make it more dynamic if I know that the query string param is the gclid but its' value is dynamically change?

如果我知道查询字符串param是gclid但它的'值是动态变化的话,是否可以使它更具动态性?

1 个解决方案

#1


0  

cant you just replace the gclid text with the variable that you receive from Adwords like this?

你不能用你从Adwords收到的变量替换gclid文本吗?

var gclidValue = whateverValue;

if (window.location.href === "http://www.example.com") { 
   url = "http://www.example.com?" + gclidValue + "=test"; 
   window.history.pushState("", "", url); 
}

#1


0  

cant you just replace the gclid text with the variable that you receive from Adwords like this?

你不能用你从Adwords收到的变量替换gclid文本吗?

var gclidValue = whateverValue;

if (window.location.href === "http://www.example.com") { 
   url = "http://www.example.com?" + gclidValue + "=test"; 
   window.history.pushState("", "", url); 
}