2014年6月24日火曜日

EC CUBEへAnalytics Eコマース トラッキングタグの設置

EC CUBEにGoogleアナリティクス Eコマーストラッキングの導入する方法

ユニーバーサルアナリティクスでの導入方法です

アナリティクスのコードが下記でない方は、アナリティクス設定からユニバーサルアナリティクスに移行してください
<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>
view raw gistfile1.js hosted with ❤ by GitHub

参考サイト:Googleアナリティクスをユニバーサルアナリティクスに移行してみた

アナリティクス設定からeコマースの設定を有効にする


アナリティクス側の設定は以上です

続いてはEC CUBEでの設定となります
EC CUBEの購入完了ページにトラッキングコードを導入します

Googleのトラッキングコードのサンプルは下記の用になっています
<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>
view raw gistfile1.js hosted with ❤ by GitHub


上記をベースにEC CUBEの変数、商品が複数ある場合に対応する様にします。

注文完了ページのcomplete.tplを開きます
/data/Smarty/templates/default/shopping/complete.tpl

下記コードをページ最下部に追記します。
<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>
view raw gistfile1.js hosted with ❤ by GitHub

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側ではわからない情報が取得できるようになります

Related Posts:

  • EC CUBEへAnalytics Eコマース トラッキングタグの設置EC CUBEにGoogleアナリティクス Eコマーストラッキングの導入する方法 ユニーバーサルアナリティクスでの導入方法です アナリティクスのコードが下記でない方は、アナリティクス設定からユニバーサルアナリティクスに移行してください 参考サイト:Googleアナリティクスをユニバーサルアナリ… Read More
  • ECCUBE3正式版のインストール(さくらVPS)さくらVPSサーバへ晴れて正式に3となったECCUBEをサーバーへインストールしていきす。 サーバーの構成とバージョンは下記 CentOS:6.6 Apache:2.2.15 PHP:5.6.10 PostgreSQL:9.4.1 phpPgAdminはインストールされているものとします。 E… Read More
  • 【ECCUBE】バナーやプラグインのクリック数を調べるバナーを貼ったけど、どれ位クリックされてるの?? 新着商品やニュース、最近売れた商品やランキング等、販促系プラグインを色々入れてみたけど、どのプラグインが効果あるの?? アナリティクスで解析しても、どのキーワードで検索されたか、どこから来たか、どの商品が人気かはわかるけど、自分たちの作ったバナーや… Read More

0 コメント: