0

Wordpress サイトのリンクを変更して、すべてのサードパーティ リンクを追跡する方法を探しています。

Google アナリティクスで正しいトラッキング コードを作成する方法に関するヘルプを見つけることができましたが、プロセスの 2 番目の部分は、特定のリンク属性を追加することです。

これが彼らが私が複製することを提案する例です:

<'a href="www.blog-hosting-service.com/myBlog" onclick="_gaq.push(['_link', 'www.blog-hosting-service.com/myBlog']); false を返す;" >ブログを見る

このコードリンク属性を挿入できる場所を知っている人はいますか? Google アナリティクスを介して外部クリックを収集できますか?

4

1 に答える 1

0

私の意見では、JQueryが最良の方法です。

// start by getting the current page path (the one you are sending to tracker)

var pathname = window.location.pathname;

// ready handler to change the links on hosts not equal to location host

$(document).ready(function() {

    $('a[href^="http://"]').filter(function() {

        return this.hostname && this.hostname !== location.hostname;

    }).click(function(e) {

        _gaq.push(['_link', pathname]);

    });
});
于 2013-04-19T22:09:42.287 に答える