Open bluetch opened 1 month ago
In most cases, this is a race condition. The state change needs a bit longer than the title being read for the dataLayer (_mtm). Make sure that the page state has been fully applied before triggering the datalayer push.
What happened?
React website using Matomo, but page title always delay for last page
What should happen?
I expect to track correct and latest page title in Matomo by React. or is there any standard react sample for Matomo?
How can this be reproduced?
`import React, { useEffect } from "react"; import { API_STATUS, useAPI, useAuth } from "@/hooks"; import { ROLE_TYPE } from "@/constants"; import { IAboutData } from "@/pages/about"; import { Helmet } from 'react-helmet';
export const Matomo: React.FC = () => { const { config, meData } = useAuth();
/--- API calls ---/ const { data: sageData, fetchFunc: fetchSageData, status: sageStatus } = useAPI("/settings/sage", []);
useEffect(() => { if (!config || Object.keys(config).length === 0 || !meData) { return; }
}, [config, meData, sageData, fetchSageData]);
useEffect(() => { if (!config || Object.keys(config).length === 0 || !meData || sageStatus !== API_STATUS.SUCCESS || !sageData) { return; } const title = Helmet.peek()?.title;
}, [config, meData, sageData, sageStatus, Helmet]);
return null; } `
Matomo version
5.1.0
PHP version
No response
Server operating system
No response
What browsers are you seeing the problem on?
Chrome
Computer operating system
No response
Relevant log output
No response
Validations