❗️旧タグのサポート終了に関するお知らせ 旧トラッキングコード(旧タグ)のサポートは終了いたしました。 |
SiTest はデフォルトでは「パラメータ以下を除いた URL のページ」をトラッキングするので、URL に付与されたパラメータによって移動先のページが分かれている場合、それぞれのページのサイト訪問者の行動データを合わせて計測してしまいます。
URL に付与されたパラメータによって移動先が分かれるページを正しくトラッキングするには「パラメータごとにページの移動先が分かれる URL であると宣言したトラッキングコード」を、トラッキングするページのソースコード上の <head>
タグ内に設置して、移動先のページを切り分けます。
以下にページを切り分けるためのトラッキングコードの例を掲載します。
例)URL に付与された「p=」でページを切り分ける
<script>
(function(PID){
var s_params = location.search.split("?")[1];
var param;
if(s_params){
param = s_params.split("&").filter(function(it){ return it.match(/^p=/); }).join("&");
if(!param){
param = "";
}
}
var name = decodeURIComponent(location.hostname + location.pathname);
if (param){
name = name + "?" + param;
}
var script = document.createElement("script");
script.src = "https://tracking.sitest.jp/tag?p=" + PID + "&u=" + encodeURIComponent(location.origin + location.pathname + location.search) + "&n=" + name;
script.async = true;
document.head.appendChild(script);
})("プロジェクト番号を入れる");
</script>
※「動的1」のトラッキングコードをカスタム
例)URL に付与された「p=」で「パソコン」と「スマートフォン」のページを切り分ける
<script>
(function(PID){
var dev = "";
var s_params = location.search.split("?")[1];
var param;
if(s_params){
param = s_params.split("&").filter(function(it){ return it.match(/^p=/); }).join("&");
if(!param){
param = "";
}
}
if (navigator.userAgent) {
dev = navigator.userAgent.match(/(android.*mobile|iphone|ipod|mobile\ssafari|iemobile|opera\smini|windows\sphone)/i)? "(sp)": "(pc)";
}else{
dev = "";
}
var name = dev + decodeURIComponent(location.hostname + location.pathname);
if (param){
name = name + "?" + param;
}
var script = document.createElement("script");
script.src = "https://tracking.sitest.jp/tag?p=" + PID + "&u=" + encodeURIComponent(location.origin + location.pathname + location.search) + "&n=" + name;
script.async = true;
document.head.appendChild(script);
})("プロジェクト番号を入れる");
</script>
※「動的2」のトラッキングコードをカスタム
上記のトラッキングコードの例を参考に移動先のページの切り分けを試しても正しくトラッキングできないときは「お問い合わせ」からお問い合わせください。