Googletagmanager with Turbolinks

前端 未结 4 971
攒了一身酷
攒了一身酷 2020-12-19 08:04

Can someone explain how should we properly integrate Googletagmanager with Turbolinks?

On normal pages we just copy/paste this code immediatelly after after the open

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-19 08:46

    I got page refreshes working following this guide

    It suggests that you set up a virtual url macro and pageview rule in Tag Manager, and then push it to the dataLayer:

    $(document).on('page:change', function(){
      dataLayer.push({
        'event':'pageview',
        'virtualUrl': window.location.pathname
      });
    });
    

提交回复
热议问题