Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
Make Google Tag Manager (GTM) pageview wait for spa url title

I have a React SPA that handles all the url's titles on the frontend, so the historyChange event regsitered on GTM is getting all the visited urls with their titles right.

However, on first load of the SPA, let's say, reload with F5, you can see how it takes some time until our code on the frontend is able to set the correct title. It looks like by that time, the pageview or the historyChange event has already been registered.

Here you can see how we load our GTM script, which loads analytics.js automatically because we have it linked from the GTM dashboard.

<script type="text/javascript" async="" src="https://www.google-analytics.com/analytics.js"></script>
<script type="text/javascript" async="" src="https://www.googletagmanager.com/gtm.js?id=GTM-WNJK84D"></script

Is there any way to wait for the title and avoid these incorrect data being registered?

Thanks a lot

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In your GTM config, you need to get rid of the "All Pages" trigger for the GA tag (that loads analytics.js).

Then you'll want to replace that with a custom data layer event that your SPA will push to the datalayer e.g. datalayer.push({event:'my-app-load'}) then trigger your GA tag off of this new trigger.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!