2013-07-19 166 views
0

我需要跟蹤谷歌分析中的一個pinterest按鈕。第一個代碼適用於一個HTML網站,它是在pin pin按鈕代碼之後實現的,該代碼被封裝在一個pin div中。我試圖將其應用於下面的第二個代碼,該代碼是社交媒體按鈕數組的一部分。但是我無法讓它工作。任何幫助,將不勝感激。 我在我的手機上。我後來發佈了完整的代碼,只是想把它扔到那裏。谷歌分析的pinterest社交跟蹤

<div class="pin"><a href="http://pinterest.com/pin/create/button/?url=http://www.myurl.com/testingjava.html" class="pin-it-button">Pin It</a></div> 

     <script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script> 
     <script> 
     $(document).ready(function() { 
       $('div.pin').click(function() { 
        _gaq.push(['_trackSocial', 'Pinterest', 'pin', $(location).attr('href')]); 
       }); 
     }); 
     </script> 



    'script' => ' 
    <div class="pin"><a href="http://pinterest.com/pin/create/button/?url=###URL###"  class="pin-it-button" count-layout="###layout###">Pin It</a></div> 

    <script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js">   </script> 
    <script type="text/javascript"> 
    $(document).ready(function() { 
     $(\'div.pin\').click(function() { 
      _gaq.push([\'_trackSocial\', \'Pinterest\', \'pin\', $(location).attr(\'href\')]); 
      }); 
    }); 
    </script>', 
+0

這是我在插件中使用的完整代碼,沒有工作。 – sam

回答

1

開幕腳本標籤未關閉:

<script type="text/javascript"> 
$(document).ready(function() { 
    $(\'div.pin\').click(function() { 
     _gaq.push([\'_trackSocial\', \'Pinterest\', \'pin\', $(location).attr(\'href\')]); 
     }); 
}); 
</script>', 
+0

當我把它放在這裏時,那只是一個迷霧。它在我的所有實現中都是關閉的。 – sam

+0

它是一個php插件裏面,如果這改變了什麼 – sam

+0

這也是我的興趣。我已經在Facebook,Google +和Twitter上完成了它,但從未使用過Pinterest。有插件可以幫助,但如果你有靜態HTML或一些自定義系統,你需要在工具箱中使用這個技巧。 – Muskie

0

我寫了一篇關於我使用谷歌Analytics(分析)跟蹤Pinterest的,Google +和Facebook的,和Twitter的舊的HTML頁面上的tutorial or at least an explination,我已經在我最喜歡的報價混搭中甚至在我當前僱主的最新活動頁面上使用了相同的基本技巧。

基本上jQuery用於添加事件,這不是一種技術,其他人首先想到它,但讓所有四個人一起工作是更多的工作,再加上我做了適當的結構化元數據等。