Home > 绝口不提技术 > Google Analytics 笔记 —— 异步追踪

Google Analytics 笔记 —— 异步追踪

November 6th, 2012

5,异步追踪方法
https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiBasicConfiguration
5.1 激发虚拟页面追踪
比如要追踪一个下载链接被点击,可以使用:

onclick=”_gaq.push([‘_trackPageview’, ‘/downloads/specSheet.pdf’);”

5.2 追踪事件
使用类似这样的代码,在用户鼠标点击时记录一次事件追踪

onclick=”_gaq.push([‘_trackEvent’, ‘Videos’, ‘Play’, ‘Baby\’s First Birthday’,1]);”

有如下参数:
1,catagories:事件的分类,必须有
2,action:事件的名称,必须有
3,label:给事件一 个描述,可选
4,value:事件有关的一个数值,需要是一个数字,可选,注意别带引号,我就不小心加了引号搞的没数据。
5,non-interaction:按照官方解释这是一个bool值,默认是true,意思是不计算跳出率

5.3 记录电子商务事件
添加商品: _addItem(orderId, sku, name, category, price, quantity)
_gaq.push([‘_addItem’,
‘1234’,         // order ID – necessary to associate item with transaction
‘DD44’,         // SKU/code – required
‘T-Shirt’,      // product name – necessary to associate revenue with product
‘Olive Medium’, // category or variation
‘11.99’,        // unit price – required
‘1’             // quantity – required
]);
添加交易
_addTrans(orderId, affiliation, total, tax, shipping, city, state, country)
_gaq.push([‘_addTrans’,
‘1234’,           // order ID – required
‘Womens Apparel’, // affiliation or store name
‘28.28’,          // total – required
‘1.29’,           // tax
‘15.00’,          // shipping
‘San Jose’,       // city
‘California’,     // state or province
‘USA’             // country
]);
追踪交易 _trackTrans()
Sends both the transaction and item data to the Google Analytics server. This method should be called after _trackPageview(), and used in conjunction with the_addItem() and addTrans() methods. It should be called after items and transaction elements have been set up.
_gaq.push([‘_trackTrans’]);

绝口不提技术 ,

  1. No comments yet.
  1. No trackbacks yet.