重定向之前,我应该在GTM上使用eventCallback吗? [英] Should i use eventCallback for GTM before redirecting?
本文介绍了重定向之前,我应该在GTM上使用eventCallback吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我了解我应该在重定向到外部网站之前使用hitCallback或eventCallback,以确保在重定向之前触发了代码,但是我想知道在重定向到同一网站中同一网站内的其他页面之前,我是否也应该使用它们标签?
I understand that i should use hitCallback or eventCallback before redirecting to an external websites to make sure that the tags got fired before redirecting, but im wondering if i should use them too before redirecting to other page within the same website in the same tab?
如果您能确认我的以下代码是否正确,并保证在重定向之前发送该事件,我也将不胜感激
also i would appreciate if you can confirm if my below code is correct and will gurantee to send that event before redirecting
var review_url = 'https://google.com'
setTimeout(redirect_url, 2000);
var url_redirected = false;
function redirect_url() {
if (!url_redirected) {
url_redirected = true;
if (review_url !== '') {
document.location = review_url;
}
}
}
dataLayer.push({
'marketplace' : marketplaceUpper,
'review-source' : review_source,
'event' : 'CreateReviewClick',
'eventCallback' : function() {
redirect_url();
}
});
推荐答案
这是正确的语法:
var targetUrl = "https://www.google.com";
window.dataLayer.push({
'marketplace' : marketplaceUpper,
'review-source' : review_source,
'event' : 'CreateReviewClick',
'eventCallback' : function() {
window.location = targetUrl
},
'eventTimeout' : 2000
});
这篇关于重定向之前,我应该在GTM上使用eventCallback吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文