Google Tag Manager and Single Page apps

后端 未结 2 1977
刺人心
刺人心 2021-02-01 19:50

I\'m trying to integrate Google Tag Manager with my Ember app. I\'m having a hard time understanding how to notify GTM that the page changed, and send a page view event.

2条回答
  •  长发绾君心
    2021-02-01 20:24

    This was asked quite a while ago. With the current feature set of GTM, you can easily set up SPA page tracking without much trouble.

    First, go to Triggers and create a new trigger. Select History Change as the trigger type. This will create a trigger that fires every time the location history changes.

    Then create a new Tag of Universal Analytics type and set it up as per the screenshot below.

    [Universal Analytics tag configuration1

    As for the trigger, set the previously defined History Change trigger, and you're done. Every time a navigation occurs in your SPA, a page view event with the proper page path will be triggered.

    EDIT: as trognaders pointed out in a comment, this does not track the initial page view. To remedy, simply add an additional trigger for your tag that fires on the Page View event (All Pages). See screenshot below.

提交回复
热议问题