To track clicks on a div using google analytics

后端 未结 2 2203
感情败类
感情败类 2021-02-20 13:38

I have multiple DIVs with unique IDs. Each DIV onclick slides down and shows some content below it.

I would like to track the clicks on each DIV to know which DIV is be

2条回答
  •  眼角桃花
    2021-02-20 13:57

    Check out the GA page on Event Tracking: https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide

    The basic idea is:

    var someDiv = document.getElementById('someDiv');
    someDiv.addEventListener('click', function(){
        _gaq.push(['_trackEvent', 'someDiv', 'click']);
    }, false);
    

提交回复
热议问题