javascript 跟踪tel:和mailto:点击Google Analytics和jQuery

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 跟踪tel:和mailto:点击Google Analytics和jQuery相关的知识,希望对你有一定的参考价值。

jQuery(document).ready(function(){
  
  //set up the vars
    var eCat = 'contact',
        eAct = '',
        eLabel = window.location.pathname;
  
  //target href attributes that begin tel: 
  jQuery(document).on('click','[href^="tel:"]', function(e) {
    
        //set the action as tel
        eAct = 'tel:'+ jQuery(this).attr('href');
        
        //track event
        ga('send', 'event', eCat, eAct, eLabel ); 
    
  });
  
    //target href attributes that begin mailto:
  jQuery(document).on('click','[href^="mailto:"]', function(e) {
    
        //set the action as email
        eAct = 'email:' + jQuery(this).attr('href');
        
        //track event
        ga('send', 'event', eCat, eAct, eLabel ); 
        
  });
  
});

以上是关于javascript 跟踪tel:和mailto:点击Google Analytics和jQuery的主要内容,如果未能解决你的问题,请参考以下文章