Use google tag manager install GA4 for SPA but the field page is not work

Viewed 637

I use Google Tag Manager to install GA4 for SPA (single page application).

I search a lot of articles about setting SPA and it seems like I need to add a page field. I tried to put the value as below but not one succeeded. I used Google Tag Manager debug mode to check the page view event was hit.

  • {New History Fragement}

  • {Page Path}{New History Fragement}

  • {Page Path}#{New History Fragement}

  • constant like /testGTM

  • custom javascript like below

    function() {   return window.location.pathname + window.location.search + window.location.hash; }

Even I put the constant like testGTM, I still can not see the data contain testGTM. The page view data is collected but the URL is not the same as I expected. 

Did anyone meet the same problem? Or the field page doesn't work anymore. Thank you.

Sample Setting GA4 in Google Tag Manager

1 Answers

I found out how to solve this problem.

First, click 「event」->「All event」.

Second, click「custom definition management」.

Last, click 「create custom dimension」and enter "page" in the parameter name.

After the above instruction, we can get the "page" data as normal.

How to Check

There are 3 ways to check

1.Engagement -> Event -> + custom(event scope)

2.Engagement -> Event -> click each event -> see past 30mins event's parameters

3.Engagement -> Event -> click each event -> scroll down to see parameter

P.S. I use the Japanese version so maybe the translations are different.

create custom dimension

Related