當前位置:編程學習大全網 - 編程語言 - 谷歌分析如何使用及工作原理

谷歌分析如何使用及工作原理

谷歌分析基於JS,分成老式UA手寫代碼方式實施,和傻瓜GTM容器拖拽實施,但是前者用的多,許多公司只是向GTM裏面放手寫的代碼,而不用傻瓜拖拽方法。具體老式實施代碼如下:

<!-- Global site tag (gtag.js) - Google Analytics -->

<script type="text/javascript" src="/gtag/js?id=UA-188325670-1"></script>

<script type="text/javascript">

window.dataLayer = window.dataLayer || [];

function gtag() { dataLayer.push(arguments); }

gtag('set', 'dimension1',“mytest”);

gtag('set', 'dimension2', document.referrer);

gtag('set', 'dimension3', document.URL);

gtag('set', 'dimension4', document.title);

gtag('js', new Date());

gtag('config', 'UA-188325673-1');

gtag('event', 'purchase', {

"transaction_id": "24.031608523954162",

"affiliation": "Google online store",

"value": 23.07,

"currency": "USD",

"tax": 1.24,

"shipping": 0,

"items": [

{

"id": "P12345",

"name": "Android Warhol T-Shirt",

"list_name": "Search Results",

"brand": "Google",

"category": "Apparel/T-Shirts",

"variant": "Black",

"list_position": 1,

"quantity": 2,

"price": '2.0'

},

{

"id": "P67890",

"name": "Flame challenge TShirt",

"list_name": "Search Results",

"brand": "MyBrand",

"category": "Apparel/T-Shirts",

"variant": "Red",

"list_position": 2,

"quantity": 1,

"price": '3.0'

}

]

});

</script>

然後在GA後臺的 自定義-》自定義維度裏面創建 dimention1=

dimention[n]=

並點擊啟用電子商務即可。

  • 上一篇:黔西南民族職業技術學院是公辦還是民辦
  • 下一篇:文件格式分類
  • copyright 2024編程學習大全網