ユニーバーサルアナリティクスでの導入方法です
アナリティクスのコードが下記でない方は、アナリティクス設定からユニバーサルアナリティクスに移行してください
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | |
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); | |
ga('create', 'UA-★★★★★★★★-★', 'your-site.com'); | |
ga('send', 'pageview'); | |
</script> |
参考サイト:Googleアナリティクスをユニバーサルアナリティクスに移行してみた
アナリティクス設定からeコマースの設定を有効にする

アナリティクス側の設定は以上です
続いてはEC CUBEでの設定となります
EC CUBEの購入完了ページにトラッキングコードを導入します
Googleのトラッキングコードのサンプルは下記の用になっています
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
ga('ecommerce:addTransaction', { | |
'id': '1234', // Transaction ID. Required. | |
'affiliation': 'Acme Clothing', // Affiliation or store name. | |
'revenue': '11.99', // Grand Total. | |
'shipping': '5', // Shipping. | |
'tax': '1.29' // Tax. | |
}); | |
ga('ecommerce:addItem', { | |
'id': '1234', // Transaction ID. Required. | |
'name': 'Fluffy Pink Bunnies', // Product name. Required. | |
'sku': 'DD23444', // SKU/code. | |
'category': 'Party Toys', // Category or variation. | |
'price': '11.99', // Unit price. | |
'quantity': '1' // Quantity. | |
}); | |
ga('ecommerce:send'); | |
</script> |
上記をベースにEC CUBEの変数、商品が複数ある場合に対応する様にします。
注文完了ページのcomplete.tplを開きます
/data/Smarty/templates/default/shopping/complete.tpl
下記コードをページ最下部に追記します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
ga('require', 'ecommerce', 'ecommerce.js'); | |
ga('ecommerce:addTransaction', { | |
id: '<!--{$orderId}-->', // Transaction ID - this is normally generated by your system. | |
affiliation: '', // Affiliation or store name | |
revenue: '<!--{$total}-->', // Grand Total | |
shipping: '<!--{$deliv_fee}-->' , // Shipping cost | |
tax: '<!--{$tax}-->' }); // Tax. | |
<!--{section name=cnt loop=$arrItems}--> | |
ga('ecommerce:addItem', { | |
id: '<!--{$orderId}-->', // Transaction ID. | |
sku: '<!--{$arrItems[cnt].product_code}-->', // SKU/code. | |
name: '<!--{$arrItems[cnt].product_name}-->', // Product name. | |
category: '', // Category or variation. | |
price: '<!--{$arrItems[cnt].price}-->', // Unit price. | |
quantity: '<!--{$arrItems[cnt].quantity}-->' }); // Quantity. | |
<!--{/section}--> | |
ga('ecommerce:send'); | |
</script> |
ecommerce:addTransactionで基本的な注文情報、ecommerce:addItemで注文された商品情報を渡しています。
{section name=cnt loop=$arrItems}で注文された商品全部を取得しています
affiliationとcategoryは入れていません
以上でアナリティクスに情報が送信されます
スマホ、モバイルの購入情報の取得はそれぞれのcomplete.tplに上記コードを追記して下さい。
/data/Smarty/templates/sphone/shopping/complete.tpl
/data/Smarty/templates/mobile/shopping/complete.tpl
どの検索キーワードや参照サイトが商品の購入につながっているのか、PC・スマホの転換率はいくつか等、EC CUBE側ではわからない情報が取得できるようになります
0 コメント:
新しいコメントは書き込めません。