user8607541
user8607541

Reputation:

Google Analytics using react-ga recommended react-router implementation uses page title from previous route

Apologies if this is a duplicate question or has been addressed elsewhere but I haven't been able to find an answer. I am trying to integrate google analytics in a react app that uses react-router-dom as per https://github.com/react-ga/react-ga/wiki/React-Router-v4-withTracker. I am using BrowserRouter and the React Hooks [TypeScript] code with no modifications from the link provided.

The resulting beacon from google analytics always has the correct page route, but uses the title from the previous page. This is an issue because in the realtime report for pageviews, the same route (page) with a different page title is reported as a separate metric.

Is this an issue or am I missing something? If it is an issue, has anyone found a workaround with or without the react-ga module?

Upvotes: -1

Views: 503

Answers (1)

user8607541
user8607541

Reputation:

Since this is a new site with no GA history I ended up implementing a GA4 property using react-ga4 instead. For pageviews you don't need anything other than an initialize call.

Upvotes: 1

Related Questions