将Google Analytics出站点击和Javascript“减速”相结合

问题描述:

我已经实施了用于出站点击跟踪的正确通用GA,但我还实施了其中一个“加速碰撞”弹出消息,当有人单击异地时链接,使用下面的JavaScript。 (银行客户端 - 需要加速缓冲)将Google Analytics出站点击和Javascript“减速”相结合

这会以任何方式“突破”GA出站点击跟踪吗? (用户在点击看到一个模式对话框弹出与免责声明和“继续”或“拒绝”按钮的选择。)

$(document).ready(function() { 
$('.external').click(function() { 
var link = $(this).attr('href'); 

$('<div>By accessing this link you will be leaving the site...</div>').dialog({ 
    title: "Third-Party Site Disclaimer", 
    modal : true, 
    overlay: { 
    backgroundColor: '#fff', 
    opacity: 1 
    }, 
    buttons: { 
    'Continue': function() { 
     $(this).dialog('close').remove(); 
     window.open(link); 
    }, 
    'Decline': function() { 
     $(this).dialog('close').remove(); 
     return false; 
    } 
    } 
}); 

return false; 
}); 
}); 

谷歌的出站点击跟踪代码,我在那里有:

<script> 
    /** 
    * Function that tracks a click on an outbound link in Analytics. 
    * This function takes a valid URL string as an argument, and uses that URL string 
    * as the event label. Setting the transport method to 'beacon' lets the hit be sent 
    * using 'navigator.sendBeacon' in browser that support it. 
    */ 
    var trackOutboundLink = function(url) { 
     ga('send', 'event', 'outbound', 'click', url, { 
     'transport': 'beacon', 
     'hitCallback': function(){document.location = url;} 
     }); 
    } 
    </script> 
+0

你自己测试过吗? –

+0

您能否提供您用于出站链接跟踪的方法?我的猜测是,现在只跟踪“意图”离开......您需要在此模式的“继续”和“拒绝”功能中添加一个事件发送,以用于更明确的用户操作。 – GreatBlakes

+0

我在上面添加了出站点击代码。谢谢大家 - 这超出了我。 –

不知道您如何设置出站链接跟踪,这里是我将GA事件放置在您提供的代码中的位置(以及我如何命名每个类别,操作和标签)。

$(document).ready(function() { 
    $('.external').click(function() { 
    var link = $(this).attr('href'); 
    ga('send', 'event', 'Outbound Link', 'Intent', link); 

    $('<div>By accessing this link you will be leaving the site...</div>').dialog({ 
     title: "Third-Party Site Disclaimer", 
     modal : true, 
     overlay: { 
     backgroundColor: '#fff', 
     opacity: 1 
     }, 
     buttons: { 
     'Continue': function() { 
      ga('send', 'event', 'Outbound Link', 'Disclaimer Continue', link); 
      $(this).dialog('close').remove(); 
      window.open(link); 
     }, 
     'Decline': function() { 
      ga('send', 'event', 'Outbound Link', 'Disclaimer Decline', link); 
      $(this).dialog('close').remove(); 
      return false; 
     } 
     } 
    }); 

    return false; 
    }); 
}); 

你现在会跟踪出站链接的意图,然后继续跟踪/跌幅为单独行动。

+0

非常感谢 - 我刚刚添加了来自Google的出站跟踪代码 - 上面的答案仍然有效吗?我非常感谢帮助。 –

+0

非常感谢 - 我一直在测试这些代码,我相信它正在工作。感谢帮助! –