Skip to content

Latest commit

 

History

History
47 lines (38 loc) · 705 Bytes

tagmanager_setup.md

File metadata and controls

47 lines (38 loc) · 705 Bytes

Tagmanager setup

For Nextjs

app.tsx

const App = () => {
  return (
    <>
      {process.env.NEXT_PUBLIC_GTM_ID && (
        <LoadTagManager
            measurementID={process.env.NEXT_PUBLIC_GTM_ID}
        />
      )}
    </>
  );
};

Usage

import {
    EventType,
    pushDataLayerEvent,
} from '@freshheads/analytics-essentials';

pushDataLayerEvent({
    type: EventType.CLICK,
    name: 'hero_button_click',
});

Optional params

pushDataLayerEvent({
    type: EventType.CLICK,
    name: 'hero_button_click',
    context: {
      // context is typed based on type
      // you can always extend context with your custom properties
    }
}),