Skip to content

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

@tiffanynguyen0211

Description

@tiffanynguyen0211

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? 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions