Google Analytics and Tag Manager, support for cust

2019-09-11 07:55发布

Just starting with Google Tag Manager. In my analytics setup I am sending custom page paths to canonicalize or "unify" the page path since in the web app there can be many different URLs for the same page. Example:

/?action=view
/view
/view_page

and in my GA for that page I'm sending:

ga('send', 'pageview', '/view');

I can't figure out how to set this up with GTM. I have access to the server side so I can make any necessary changes there.

I tried setting it in the dataLayer link this:

<script>
  dataLayer = [{
    'pageview': '/view'
  }];
</script>

And I can see the data in the datalayer debug/preview, but it doesn't appear this is actually being set as the page path. I am guessing something needs to be set up on the GTM admin to map the dataLayer value?

1条回答
男人必须洒脱
2楼-- · 2019-09-11 08:53

If you want to push the pagepath as a dataLayer parameter, then you would need to

  1. configure a dataLayer type variable with the value of pageview (this is how the value you've defined in the dataLayer gets passed into GTM).
  2. In your base pageview tag, you would need to set the page field (under "Fields to Set") with the value of the name of the dataLayer type variable.

It's worth mentioning that your dataLayer declaration MUST come before the GTM container. In this way, you can set your pageview to fire on the regular Page View trigger.

查看更多
登录 后发表回答