Google Tag Manager Preview does not display when navigating to pages with TurboLinks

雨燕双飞 提交于 2019-12-07 03:12:27

This has to do with how the preview mode injects the debugger iframe.

It is injected on the initial page load, but since turbolinks replaced the entire body it also removes the preview panel from -ALL- subsequent page reloads.

It is sadly pretty much how it is and not much one can do about it.

Your GTM implementation is probably still working, but preview mode in Google Tag Manager is not compatible with turbolinks page reloads.

And yes, this makes debugging GTM in turbolinks enhanced sites a major pain.

dataLayer.push(
   {'userID': '<%= current_user.id %>'},
   {'userCategory': 'User'}
);

instead please try

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
    'userID': '<%= current_user.id %>',
    'userCategory': 'User'
});

This is untested.

I have noticed your use of braces '{'

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!