> ## Documentation Index
> Fetch the complete documentation index at: https://docs.notifly.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up Google Tag Manager

> Use the Notifly template in Google Tag Manager to initialize the SDK, set user information, and track events.

Add the Notifly custom template to Google Tag Manager (GTM) to configure SDK initialization, user information, and event tracking without changing your application code.

## 1. Install the Notifly custom template

1. Download the latest template.
   Download the template from the [releases page](https://github.com/notifly-tech/notifly-gtm-template/releases).
   * Korean template: **template.ko.tpl**
   * English template: **template.tpl**. The steps below use this version.
2. In GTM, open **Templates** near the bottom of the left menu. Under **Tag Templates**, create a template. If the list is empty, click **Add tag template**.

   ![Create a template](https://mintcdn.com/notifly/dcFO7QF5JScPffiH/images/i18n/en/cafe24/gtm-import-1.png?fit=max\&auto=format\&n=dcFO7QF5JScPffiH\&q=85\&s=23c63fa414c5ffb84214f4be8ca52db0)
3. In the template editor, select **⋮ > Import** in the upper right. Import the `.tpl` file you downloaded.

   ![Import the template](https://mintcdn.com/notifly/dcFO7QF5JScPffiH/images/i18n/en/cafe24/gtm-import-2.png?fit=max\&auto=format\&n=dcFO7QF5JScPffiH\&q=85\&s=1d3650173bbcd6fbdc3387ebc0022b01)
4. Click **Save**. The **Template created** message appears at the bottom left.

   ![Template created](https://mintcdn.com/notifly/dcFO7QF5JScPffiH/images/i18n/en/developer-guide/gtm/gtm-import-3.png?fit=max\&auto=format\&n=dcFO7QF5JScPffiH\&q=85\&s=f6f9016ddd5483f3010c3e902dc0f941)

## 2. Create an SDK initialization tag

1. In Google Tag Manager, open **Tags** in the left menu and click **New**.
2. Name the tag, then click **Tag Configuration**.
3. Under **Custom** at the bottom of the tag type list, select **Notifly Javascript SDK**.

   ![Custom template selection](https://mintcdn.com/notifly/0_mniRtlC78csfem/images/i18n/en/developer-guide/gtm/gtm-init-1.png?fit=max\&auto=format\&n=0_mniRtlC78csfem\&q=85\&s=8aadfc6ac1c5cfddf0b49ad7d933a875)
4. In the tag configuration, set **Tag Type** to **Initialize (initialize)** (**SDK 초기화 (initialize)** in the Korean template), then enter **Project ID\*** and **Username\***. **Password\*** is a placeholder for backward compatibility. Do not enter a real password or API Secret Key. Enter the same nonempty value as **Username\***. See the [Notifly SDK initialization options](https://docs.notifly.tech/en/developer-guide/javascript-sdk.md#2-initialize-the-sdk).

   ![Tag type](https://mintcdn.com/notifly/0_mniRtlC78csfem/images/i18n/en/developer-guide/gtm/gtm-init-2.png?fit=max\&auto=format\&n=0_mniRtlC78csfem\&q=85\&s=cf94f66bc29c469e0048422cfc58539c)
5. Advanced settings

* Set **Tag firing options** to **Once per page**.
* Set the trigger to **Initialization - All Pages**.

  ![Advanced settings](https://mintcdn.com/notifly/0_mniRtlC78csfem/images/i18n/en/developer-guide/gtm/gtm-init-3.png?fit=max\&auto=format\&n=0_mniRtlC78csfem\&q=85\&s=01afa83eba9712820d2211284b5d97c4)

  ![Trigger](https://mintcdn.com/notifly/0_mniRtlC78csfem/images/i18n/en/developer-guide/gtm/gtm-init-4.png?fit=max\&auto=format\&n=0_mniRtlC78csfem\&q=85\&s=32ff873273afc475e66c408c199aa159)

## 3. Manage users

Set `userId` and `userProperties` for campaign targeting and personalization. You can also store values such as push notification consent in `userProperties` and use them in filters.

> [!NOTE]
>
> The **SDK initialization tag** must run first.

### 1. Set the user ID (setUserId)

1. Go to **Tags > New**, name the tag, for example **Notifly – setUserId**, then click **Tag Configuration**.

2. Set **Tag Type** to **Set User ID (setUserId)** (**유저 아이디 등록 (setUserId)** in the Korean template). In the **User ID** field (**유저 아이디** in the Korean template), select a [GTM variable](https://support.google.com/tagmanager/answer/7683362), such as `{{User ID}}`.\\

   ![Tag type](https://mintcdn.com/notifly/0_mniRtlC78csfem/images/i18n/en/developer-guide/gtm/gtm-set-user-id-1.png?fit=max\&auto=format\&n=0_mniRtlC78csfem\&q=85\&s=564fbe20a5a70f3f09550b2584c87d3c)

3. In **Tag Sequencing**, configure the SDK initialization tag to run first. **Other tags do not work unless the initialization tag has run.**

   ![Tag sequencing](https://mintcdn.com/notifly/0_mniRtlC78csfem/images/i18n/en/developer-guide/gtm/gtm-set-user-id-2.png?fit=max\&auto=format\&n=0_mniRtlC78csfem\&q=85\&s=eea3b48abea8ff15e6c8e3c60a76afd9)

4. Use a custom event that fires after sign-in, such as `login_success`, as the trigger.

   ![Trigger](https://mintcdn.com/notifly/0_mniRtlC78csfem/images/i18n/en/developer-guide/gtm/gtm-set-user-id-3.png?fit=max\&auto=format\&n=0_mniRtlC78csfem\&q=85\&s=2c017faa76f1ad26b8f5f2228c83def0)

### 2. Set user properties (setUserProperties)

> [!NOTE]
>
> **Before sending sensitive user properties**
>
> Before sending custom user properties that need protection, such as names or addresses, register each key under **User Management > User List > Property management** in the console and enable encryption. Use the same key names as in the data you send.
>
> For setup instructions and limitations, see the [property management guide](https://docs.notifly.tech/en/user-guide/users/properties.md).

1. Go to **Tags > New**, name the tag, for example **Notifly – setUserProperties**, then open **Tag Configuration**.

2. Set **Tag Type** to **Set User Properties (setUserProperties)** (**유저 속성 등록 (setUserProperties)** in the Korean template). Map the properties you want to register to the corresponding [GTM variables](https://support.google.com/tagmanager/answer/7683362).

   ![Tag type](https://mintcdn.com/notifly/0_mniRtlC78csfem/images/i18n/en/developer-guide/gtm/gtm-set-user-props-1.png?fit=max\&auto=format\&n=0_mniRtlC78csfem\&q=85\&s=fb9f0e0efdfe2cb1d6217aaed900d670)

3. In **Tag Sequencing**, configure `setUserId` to run before `setUserProperties`.

   ![Tag sequencing](https://mintcdn.com/notifly/0_mniRtlC78csfem/images/i18n/en/developer-guide/gtm/gtm-set-user-props-2.png?fit=max\&auto=format\&n=0_mniRtlC78csfem\&q=85\&s=bb7929e3d9b47a3917a2a78eeeeba314)

> [!NOTE]
>
> * Email delivery requires **`$email`**. Kakao AlimTalk, Friendtalk, and SMS delivery require **`$phone_number`**. LINE message delivery requires **`$line_user_id`**.
> * Use reserved keys exactly as written, such as `$email`, `$phone_number`, and `$line_user_id`.

> [!WARNING]
>
> Leave **User ID** empty in the **Set User ID (setUserId)** tag that runs on sign-out. This disassociates the current device from the user.

## 4. Log events (trackEvent)

Send user actions, such as clicks, views, and purchases, as events for segmentation, triggers, and performance analysis.

> [!NOTE]
>
> * Configure tag sequencing so the event tag runs **after the SDK initialization tag**.
> * In **Set of Keys for User Segmentation** (`segmentationEventParamKeys`), you can add **at most one key**.

1. Go to **Tags > New**, name the tag, for example **Notifly – trackEvent**, then open **Tag Configuration**.
2. Set **Tag Type** to **Track Event (trackEvent)** (**이벤트 로깅 (trackEvent)** in the Korean template) and enter an event name. If needed, map event parameters to GTM variables and add a key under **Set of Keys for User Segmentation**.

   ![Tag type](https://mintcdn.com/notifly/0_mniRtlC78csfem/images/i18n/en/developer-guide/gtm/gtm-track-event-1.png?fit=max\&auto=format\&n=0_mniRtlC78csfem\&q=85\&s=9f317bc5115774d7e674b7a9f8d128d7)
3. In **Tag Sequencing**, configure the tag to run after the SDK initialization tag.
4. For example, use GTM's [built-in variable](https://support.google.com/tagmanager/answer/7182738) **Click ID** and [built-in trigger](https://support.google.com/tagmanager/answer/7679320) **Click - All Elements** to send the clicked element's `id` as `element_id`. Add `element_id` under **Set of Keys for User Segmentation**.

   ![Variables](https://mintcdn.com/notifly/0_mniRtlC78csfem/images/i18n/en/developer-guide/gtm/gtm-track-event-2.png?fit=max\&auto=format\&n=0_mniRtlC78csfem\&q=85\&s=622544efda44de3938f5dafa9f2349df)

   ![Event trigger](https://mintcdn.com/notifly/0_mniRtlC78csfem/images/i18n/en/developer-guide/gtm/gtm-track-event-3.png?fit=max\&auto=format\&n=0_mniRtlC78csfem\&q=85\&s=cf3c359d9c27da2c250135580b4dafb0)

## 5. Test the integration

After you install the SDK, follow [Test your integration](https://docs.notifly.tech/en/integration-test.md) to verify event collection and push notification delivery.

## 6. Configure web push notifications (advanced)

* To use web push notifications, add a script to your website in addition to the Google Tag Manager configuration.
* Follow the [web push setup section of the JavaScript SDK guide](https://docs.notifly.tech/en/developer-guide/javascript-sdk.md#1-basic-setup) to add `notifly-service-worker.js` to your website.
* For integration questions, email [contact@notifly.tech](mailto:contact@notifly.tech).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.