Google Analytics - Single Page Site - Click Tracking

前端 未结 3 1427
逝去的感伤
逝去的感伤 2021-01-15 13:32

The site in question is http://getstefan.com

Its a single page portfolio site and I have tried using jQuery to add Google Analytics click tracking to every anchor ta

3条回答
  •  生来不讨喜
    2021-01-15 14:08

    First Your anchors don't have an ID assigned, so the code is doing exactly what it should be reporting 'undefined' as the value for something that doesn't exist. For example

    
    

    Second, don't use the timer.

    jQuery(window).load(function(){
            setTimeout(loadOnClick,8000)
        });
    

    should be replaced by

    jQuery(document).ready(function(){
            loadOnClick();
        });
    

    so you don't have to wait 8 seconds and can just assign everything when the DOM is ready.

提交回复
热议问题