Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GTM warning: Command out of order from Tag diagnostics #135

Open
tiffanynguyen0211 opened this issue Dec 16, 2024 · 0 comments
Open

GTM warning: Command out of order from Tag diagnostics #135

tiffanynguyen0211 opened this issue Dec 16, 2024 · 0 comments

Comments

@tiffanynguyen0211
Copy link

tiffanynguyen0211 commented Dec 16, 2024

Hi I got reported with this error https://support.google.com/tagmanager/answer/14779480#zippy=%2Cshow-me-an-example from Tag diagnostics

the issue is it said the config is called after the send event, but we did initialize in index.tsx and only call the first event in app.tsx, so there is no way the initialization happens before the first event was called

...
const RootApp = () => {
  useEffect(() => {

    TagManager.initialize({
      gtmId: process.env.REACT_APP_GOOGLE_TAGMANAGER_ID || "",
    });
  }, []);

  return (
        <AppWrapper />
 )

->

export const sendAnalyticsEvent = (
  eventName,
  eventData,
) => {
  eventData.event = eventName;
  TagManager.dataLayer({
    dataLayer: eventData,
  });
};

const App = () => {
useEffect(() => {
    sendAnalyticsEvent("page_view", { some_details_here });
  }, []);
....

}


so how come GTM complains that the config was happening after the first event was sent? or is the initialize missing something? 
@tiffanynguyen0211 tiffanynguyen0211 changed the title GTM error: Command out of order GTM warning: Command out of order from Tag diagnostics Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant