LoginSignup
2
7

More than 5 years have passed since last update.

GTM:URLパラメータの中身を取得する

Last updated at Posted at 2016-08-11

カスタムJavaScriptでパラメータを変数に渡す

<例>
www.test.com/?a=1111&b=2222

パラメータ部分を全部取得する

■書き方
function(){
var sample1 = decodeURIComponent(location.search);
return sample1;
}

■結果
sample1に
 a=1111&b=2222
が戻される。

sample1.png

パラメータの中身を取得する

■書き方

function(){
var sample2 = decodeURIComponent(location.search.match(/b=(.*?)(&|$)/)[1]);
return sample2;
}

■結果
sample2に
2222
が戻される。

sample2.png

2
7
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
7