MonetizationOS Docs

Push events to the data layer

What you'll build

A Surface component workflow that injects a script pushing authentication state into window.dataLayer, so analytics tools such as Google Tag Manager can read it on every page.

1. Prerequisites

  1. A Component Workflow in a Surface
  2. A page that initializes window.dataLayer (for example Google Tag Manager)

2. Add a component

Component Workflow
const :  = async ({  }) => {
  const  = {
    : "mos",
    : . === "authenticated",
    : .,
  };

  return {
    : {
      : [
        {
          : "html",
          : `<script>
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push(${.()});
</script>`,
        },
      ],
    },
  };
};

export default ;

Result

Each Surface decision injects a script that pushes an event object into window.dataLayer. In the browser console, window.dataLayer includes an entry with event, is_authenticated, and user_type.

On this page