# Send story events to Google Analytics 4 with Tag Manager

Source: https://knowledge.intractive.app/en/articles/meta-sending-story-events-to-google-analytics-4

Connect a story to Google Analytics 4 through Google Tag Manager, so you can see how many people started a story, where they dropped off, what they answered and how many clicked through. You set it up in Tag Manager, then register the extra details in Analytics so they show up in reports.

## What you need first

This setup builds on the data layer events explained in [Story events with Google Tag Manager](https://knowledge.intractive.app/en/articles/meta-story-events-with-google-tag-manager). Read it first if you haven't.

| What you need | Looks like | Where to find it |
| --- | --- | --- |
| Tag Manager container ID | `GTM-XXXXXXX` | At the top right of your Tag Manager workspace. Usually already added in Intractive. If not, add it under **Project settings** > **Tracking & scripts**: in the **Tools** section, click **Add** next to **Google Tag Manager**, paste the ID and click **Save** at the bottom of the section. You need the admin role in the project. |
| Analytics measurement ID | `G-XXXXXXXXXX` | In Analytics, under **Admin** > **Data streams** > your web stream |

\[screenshot: Project settings, Tracking & scripts, with a Google Tag Manager container ID added\]

The data stream screen also shows a **Google tag ID** that starts with `GT-`. Both work, but use the one that starts with `G-`. The steps in this article use it.

If you don't have an Analytics property yet, create one first. In Analytics, go to **Admin** > **Create property**, then add a **Web** data stream for your story's address. That is your project's custom domain if it has one, otherwise its subdomain, otherwise `web.intractive.app`. Set the time zone and currency to your own, not the defaults.

Tags you load through Tag Manager are your responsibility under GDPR, ePrivacy and similar rules. Intractive doesn't show a cookie banner for them on your behalf, so you set up consent in Tag Manager.

Without Tag Manager, a superadmin can add your Analytics measurement ID to the project directly. Stories then send their own events, such as `story_start`, `story_progress` and `story_complete`. If you use both routes with the same Analytics property, events are counted twice, so use one route per property. Ask your Customer Success Manager if you'd like the direct route instead.

## Add the Google tag

This tag loads Analytics on the page, and everything else depends on it. Its **Tag ID** decides which Analytics property receives your events. The other tags and triggers decide when to send them.

1. In Tag Manager, go to **Tags** > **New**.
2. Choose the tag type **Google tag**.
3. In **Tag ID**, enter your `G-XXXXXXXXXX` ID.
4. Set the trigger to **Initialization - All Pages**.
5. Name the tag `GA4 - Config`.
6. Click **Save**.

## Create the variables

Variables pull the details out of each story event so you can use them. Create each one under **Variables** > **New** > **Data Layer Variable**, and leave the version at its default.

| Name it | Data layer variable name | What it gives you |
| --- | --- | --- |
| `DLV - storyId` | `storyId` | Which story |
| `DLV - sessionId` | `sessionId` | One playthrough, so one visitor's run stays together |
| `DLV - milestone` | `milestone` | The milestone just passed: `0`, `25`, `50`, `75` or `100` |
| `DLV - progress` | `progress` | Percentage complete, as a whole number |
| `DLV - depth` | `depth` | How far the visitor got, as a block position counting from 1 |
| `DLV - total` | `total` | How long the story is. On progress events this is the live number of blocks, which can grow when a branch opens. On milestone events it's the story's potential length. |
| `DLV - outboundUrl` | `url` | Which link was clicked, including any UTM parameters Intractive adds |

The data layer variable name must match the story's field name exactly, including capital letters. `storyid` won't work where `storyId` is expected. If a variable comes back empty when you test, a capitalisation slip here is almost always the cause.

To capture an answer, add one more **Data Layer Variable** for each answer you care about. Use the variable name from your story with `variables.@` in front of it, for example `variables.@timeline` for a story variable called `timeline`. Each time a variable changes, the story sends the current value of every variable again.

## Create the triggers

Triggers decide when a tag fires. They're all **Custom Event** triggers, created under **Triggers** > **New**. For a condition, limit the trigger to events where the variable matches the value in the table.

| Name it | Event name | Condition |
| --- | --- | --- |
| `CE - Story Progress` | `intractiveStoryProgress` | All custom events |
| `CE - Story Start` | `intractiveStoryMilestone` | `DLV - milestone` equals `0` |
| `CE - Story Halfway` | `intractiveStoryMilestone` | `DLV - milestone` equals `50` |
| `CE - Story Complete` | `intractiveStoryMilestone` | `DLV - milestone` equals `100` |
| `CE - Variables Updated` | `intractiveVariablesUpdated` | All custom events |
| `CE - Outbound Link` | `intractiveOutboundLink` | All custom events |

The start, halfway and complete triggers use `intractiveStoryMilestone`. It fires at most once per milestone per playthrough, and its values only move forward, so you don't need **Once per page** on the tags that use them.

Milestone `0` fires as the story opens, before the visitor answers anything. Milestone `100` fires only when the story is complete. Reaching the last block isn't enough, but a story that ends by redirecting the visitor counts as complete when they reach that block. A playthrough resumed on a later visit doesn't report the milestones it passed before, including `0`.

Milestones `25` and `75` fire too, so you can add triggers for them in the same way.

## Create the event tags

Create one tag for each event you want in Analytics. Each is a **Google Analytics: GA4 Event** tag, with the measurement ID set to your `G-` ID.

| Event name to send | Details to include | Trigger |
| --- | --- | --- |
| `intractive_story_start` | `story_id`, `session_id`, `total_blocks` | `CE - Story Start` |
| `intractive_block_view` | `story_id`, `session_id`, `block_index`, `total_blocks`, `progress` | `CE - Story Progress` |
| `intractive_progress_50` | `story_id`, `session_id` | `CE - Story Halfway` |
| `intractive_story_complete` | `story_id`, `session_id`, `total_blocks` | `CE - Story Complete` |
| `intractive_answer` | `story_id`, `session_id`, plus the answers you chose | `CE - Variables Updated` |
| `intractive_outbound_click` | `story_id`, `session_id`, `link_url` | `CE - Outbound Link` |

Add each detail under **Event Parameters** as a name and a value. The value is the matching variable you created, for example parameter `story_id` with value `{{DLV - storyId}}`.

\[screenshot: GA4 Event tag in Tag Manager with event name and event parameters filled in\]

`intractive_block_view` fires each time the visitor's progress changes, usually once to twice per content block, and once when the story loads. A completed story sends roughly one to two events per content block, so the count grows with the length of the story and its branches. It's roughly 12 to 20 events only for a story of about that size. This volume is what makes drop-off analysis possible, such as 'we lose 40% of visitors at block 4', and it's well inside Analytics' free limits. If your reports feel noisy, switch this tag off first.

## Register the details in Analytics

Analytics collects your extra details but won't report on them until you register each one by hand. This step is often missed, and nothing works properly without it.

### Add custom definitions

In Analytics, go to **Admin** > **Custom definitions** and add each of these with the **Event** scope.

| Register as | Name | Event parameter |
| --- | --- | --- |
| **Custom dimension** | Story ID | `story_id` |
| **Custom dimension** | Session ID | `session_id` |
| **Custom dimension** | Link URL | `link_url` |
| **Custom metric** (integer) | Block index | `block_index` |
| **Custom metric** (integer) | Total blocks | `total_blocks` |
| **Custom metric** (integer) | Progress | `progress` |

\[screenshot: Analytics Custom definitions list with the story dimensions and metrics added\]

### Mark completion as a key event

1. In Analytics, go to **Admin** > **Events** > **Key events**.
2. Mark `intractive_story_complete` as a key event.

It then counts as a conversion and can be imported into Google Ads.

## Test, then publish

1. In Tag Manager, click **Preview** and enter a published story link. Unlike the tags a superadmin adds directly, the Tag Manager container and its events also run on builder previews and for signed-in editors.
2. Tap through the story. You should see `intractiveStoryMilestone` as the story opens and at each milestone, `intractiveStoryProgress` once on load and then once or twice per block, `intractiveVariablesUpdated` when you answer and `intractiveOutboundLink` if you click out.\
   \[screenshot: Tag Manager Preview with intractiveStoryMilestone and intractiveStoryProgress events listed\]
3. Click an event.
4. Open the **Variables** tab. Your `DLV -` variables should have values, not `undefined`.
5. Finish the story and check that the complete tag fired once, not once per remaining block.
6. In Analytics, open **Admin** > **DebugView** and watch the same events arrive with their details.
7. In Tag Manager, click **Submit** to publish. Nothing reaches real visitors until you do.

> [!TIP]
> After publishing, your own browser may keep serving the previous version of the container for up to 15 minutes. If your changes don't seem to be live, do a hard refresh before assuming something is broken.

## Read the results

Use **Reports** > **Engagement** > **Events** for the volume of each event. Use **Explore** for a free-form drop-off view: put `block_index` against event count to see exactly which block loses people.

The block where the curve flattens is where visitors commit, and everyone past it tends to finish.

Build completion rates on the start, halfway and complete events. Every later milestone is a share of the visitors who reached milestone `0`.

## Next

- [Troubleshooting story tracking](https://knowledge.intractive.app/en/articles/meta-troubleshooting)
