javascript
  • php
  • google-analytics
  • 2016-04-29 56 views 0 likes 
    0

    我有一個Shopify商店,在這裏我試圖跟蹤我網站的出站鏈接。如何使用shopify中的谷歌分析跟蹤未綁定的鏈接

    即使我找到了一些代碼。

    <script> 
        $(document).ready(function(){ 
        var localserver = "trendsnaps.com"; 
        $("a").not("a[href^='http://"+localserver+"']").not("a[href^='https://"+localserver+"']").click(function(){ 
        $(this).attr("target", "blank"); 
        ga('send', 'event', 'links', 'click', $(this).attr('href')); 
        }); 
        }); 
    </script> 
    

    但此代碼僅跟蹤的 「href」 的鏈接。我想存儲提交按鈕出去的鏈接。

    我的提交按鈕的代碼是

    <input class="btn add-to-cart-btn" onclick="window.open('{{ product.metafields.google.custom_label_0 }}');" type="submit" value="More Info At {{ product.vendor }}"/> 
    

    「product.metafields.google.custom_label_0」 是一個外部的靜態鏈接。

    如何使用相同的方式跟蹤此鏈接。

    回答

    0

    你可能鏈中的另一個功能將onclick處理

    <input class="btn add-to-cart-btn" onclick="ga('send', 'event', 'links', ...); window.open('{{ product.metafields.google.custom_label_0 }}');"...> 
    
    相關問題