質問

Googleアナリティクスを従来のアナリティクスから非同期追跡に移行しています。閉鎖タグの直前にドキュメントの詳細として一般的なスクリプトを配置しました。

このような ...

<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXXXXXX-1']);
  _gaq.push(['_trackPageview']);
 (function() {
      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>

ページの後半では、「近く」の閉じボディタグ - メソッドアレイの「_addtrans」、「_additme」、および「_tracktrans」メソッドをプログラム的にプッシュします。このような ...

    <script type="text/javascript">
        try {
                _gaq.push(['_trackPageview', '/checkout/order_confirmation.aspx']);
                _gaq.push(['_addTrans',
                  '1234',           // order ID - required
                  'Mountain View',  // affiliation or store name
                  '11.99',          // total - required
                  '1.29',           // tax
                  '5',              // shipping
                  'San Jose',       // city
                  'California',     // state or province
                  'USA'             // country
                ]);
                _gaq.push(['_addItem',
                  '1234',           // order ID - required
                  'DD44',           // SKU/code
                  'T-Shirt',        // product name
                  'Green Medium',   // category or variation
                  '11.99',          // unit price - required
                  '1'               // quantity - required
                ]);
                _gaq.push(['_trackTrans']);

        } catch (err) { }
    </script>

これは許されますか?それらはAPIドキュメントの詳細として一緒にいないので、私のeコマース追跡はまだ機能しますか?

ありがとう

役に立ちましたか?

解決

できます。同じタグである必要はありません。 _setAccountへの呼び出しはまだ最初のランでなければならないことに注意する必要があります。そして、あなたの例では、2つのページビューを発射しています。最初のものはデフォルトのdocument.location.hrefを使用し、もう1つはカスタム/仮想ページビューを使用します。それはまさにあなたが望むものではないかもしれません、あなたはページごとに単一のページビューを持っている必要があります。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top