Google Analytics; Track outgoing clicks; How?

I read this article about tracking outbound links on banners, etc.

http://seogadget.co.uk/how-to-count-your-outbound-click-stats-with-onclick-in-google-analytics/

So, I added this code to the onClick event of my href:

 javascript: pageTracker._trackPageview('/outbound/top_banners/banner_name');

is that enough?

Since I read several places, I need the "link delay" function or something else in HEADmy document before any javascript is executed!

Also, where exactly in GA (in the interface) can I view clicks?

thank

+3
source share
2 answers

: , Google Analytics, GA URL- __utm.gif. _.trackPageview() / URL- , . , _trackPageview() , GA.

, , GA () , . , GA, , .

, , - GA, , - .

, Q, - " ".

-, , onClick "false" - () http://www.outbound-link.com

diff - setTimeout. , , "100" - .

-, onclick (fnx) , , pageTracker, .

: GA ? GA, - _trackEvent() _trackPageView().

( , , ), 'click' , ( "virtual pageview" - , GA ., -, , ). , , ( Traffic and Visitors, ). , ? "" ( ) URL- . , , , .

<script type="text/javascript">
    function fnx(that) {
        try {
            var pageTracker=_gat._getTracker("UA-YOURACCOUNTHERE-PROFILE");
            pageTracker._trackPageview("http://www.outbound_link.com");
            setTimeout('document.location = "' + that.href + '"', 100)
     }catch(err){}
    }
</script>


<a href="www.outbound_link.com" onclick='fnx(this);return false;'>"Take Me Here"</a>
+4

100% - ( jQuery, jquery.js script ).

function isLinkExternal(link) {
    var r = new RegExp('^https?://(?:www.)?' + location.host.replace(/^www./, ''));
        return !r.test(link);
}

$(document).ready(function() {
    $(document).bind('click', function(e) {
        var target = (window.event) ? e.srcElement : e.target;
        while (target) {
            if (target.href) break;
            target = target.parentNode;
        }
        if (!target || !isLinkExternal(target.href)) return true;
        var link = target.href;
        link = '/outgoing/' + link.replace(/:\/\//, '/');
        _gaq.push(['_trackPageview', link]);
    });
});

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-YOURCODE-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 GA :/outgoing/http/www.example.com. . : "" " " /outgoing/http ". ! .

+2

Source: https://habr.com/ru/post/1772383/


All Articles