> For the complete documentation index, see [llms.txt](https://docs.immedio.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.immedio.io/guides/initial-setup/gtm.md).

# Google Tag Managerを使ってタグを設置する

Google Tag Managerを使ってimmedioタグを設置する方法を紹介します。

## Google Tag Managerとは

Google Tag Manager（GTM）とは、Googleが提供するタグ管理システムです。ウェブサイトの構築にご利用のCMSがScriptタグの挿入に対応していない場合、GTMを使ってimmedioのタグを挿入することができます。

## Google Tag Managerでできること

| 機能      | 説明                        |
| ------- | ------------------------- |
| タグの管理   | 複数のタグを一元管理できます            |
| トリガー設定  | 特定のページや条件でタグを発火させることができます |
| バージョン管理 | タグの変更履歴を管理できます            |
| プレビュー機能 | 公開前にタグの動作を確認できます          |

## Google Tag Managerの設定手順

### 1. GTM側の準備

1. GTMのアカウントを作成したら、ホーム画面で「アカウントを作成」をクリックします。

![GTMアカウント作成画面](https://3107207992-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTmKUVxjlMjhXsG7RSh8z%2Fuploads%2Fgit-blob-ee6053578724fafa9a066106e6f5fbd554297c7a%2Fgtm_account_creation.png?alt=media)

2. アカウント名とコンテナ名を設定し、国を「日本」に、ターゲットプラットフォームを「ウェブ」に設定します。

![GTMコンテナ設定画面](https://3107207992-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTmKUVxjlMjhXsG7RSh8z%2Fuploads%2Fgit-blob-18e54bb1cc82c03205f1073fad4f9ab2d0529b28%2Fgtm_container_setup.png?alt=media)

3. アカウントを作成したら左側メニューより「タグ」をクリックし、遷移先で「新規」をクリックします。

![GTMタグメニュー画面](https://3107207992-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTmKUVxjlMjhXsG7RSh8z%2Fuploads%2Fgit-blob-dcdbafd678e826db65b56b9cf749d9691dff83a5%2Fgtm_tag_menu.png?alt=media)

4. 遷移先で「タグの設定」をクリックし、タグタイプで「カスタムHTML」を選択します。

![GTMカスタムHTML選択画面](https://3107207992-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTmKUVxjlMjhXsG7RSh8z%2Fuploads%2Fgit-blob-fa819f3c20f30a4e4ff73adfdb8fae8a26b48950%2Fgtm_custom_html.png?alt=media)

### 2. タグの設定

1. immedio管理画面で[ルーター一覧](https://console.immedio.io/common/routers)にアクセスし、Form画面用のタグをコピーします。SnippetをGTMのHTMLの欄に貼り付けます。

![GTMスニペット貼り付け画面](https://3107207992-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTmKUVxjlMjhXsG7RSh8z%2Fuploads%2Fgit-blob-65fcc423f9e849289555ad4e4a99e2c475069d59%2Fgtm_snippet_paste.png?alt=media)

2. 次に、GTMで「トリガー」を選択し、右上の＋ボタンをクリックします。

![GTMトリガーボタン画面](https://3107207992-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTmKUVxjlMjhXsG7RSh8z%2Fuploads%2Fgit-blob-b1c5a440f831e4bf3ec56de372874fa38fd92709%2Fgtm_trigger_button.png?alt=media)

3. 「トリガーの設定」をクリックした後、右側の選択肢から「ページビュー」を選択します。

![GTMページビュー選択画面](https://3107207992-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTmKUVxjlMjhXsG7RSh8z%2Fuploads%2Fgit-blob-edfc7775564f517e9361567fca3c2c1997f656c2%2Fgtm_trigger_pageview.png?alt=media)

4. 次のページで「このトリガーの発生場所」から「一部のページビュー」選択し、フォームのページURLを入力します。

![GTMトリガーURL設定画面](https://3107207992-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTmKUVxjlMjhXsG7RSh8z%2Fuploads%2Fgit-blob-b83ea7213d208f11cc832dea1028f7fcf6ff0060%2Fgtm_trigger_url.png?alt=media)

5. ここまでのプロセスでフォーム側の設定は完了です。次に同じプロセスをThanksページ分につき繰り返して下さい。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.immedio.io/guides/initial-setup/gtm.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
