> For the complete documentation index, see [llms.txt](https://docs.exoclick.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.exoclick.com/publishers/ja/adblock/track-adblock-users-ga.md).

# Google Analytics 4でAdBlockユーザーを追跡する方法

ExoClick はあなたの広告ゾーンで発生したインプレッション、クリック、収益を追跡しますが、サイト全体のパフォーマンスや活動を測定するために使える他のツールもあります。そのうちの1つが [**Google アナリティクス**](https://support.google.com/sites/answer/97459?hl=en)で、サイトで何が起きているのかを詳しく把握できます。

設定できます **カスタムトラッキングイベント** Google アナリティクスに設定すると、Adblock を有効にしてあなたのウェブサイトを訪れているユーザー数の目安がわかります。これにより、どれだけのトラフィックを収益化できるかの把握に役立ちます。 [**ExoClick の Adblock ソリューション**](/publishers/ja/adblock/nebburokku.md).

なお、ここでは **Google アナリティクス 4** 版を参照します。というのも [Universal Analytics は 2023 年 7 月に提供終了となるため](https://support.google.com/analytics/answer/11583528?hl=en\&ref_topic=10094551).

{% stepper %}
{% step %}

## ad-units.js スクリプトを作成し、サーバーにアップロードする

ユーザーが Adblock を有効にした状態でサイトにアクセスしているかを検出するために、次の JavaScript ファイルを作成します： `ad-units.js`。このファイルは、あなたのウェブサイトを訪れるすべてのユーザーが Adblock を使用していないことを宣言します。Adblock は「ad-units」という語をブロックするため、 **このファイルが読み込まれない場合、そのユーザーは Adblock 拡張機能を使用してアクセスしているとみなします**.

.js ファイルには次の内容だけを含めればよいです：

```html
isAdBlockActive=false;
```

このファイルを作成したら、ウェブサイトのサーバーにアップロードしてください。
{% endstep %}

{% step %}

## 各ページにトラッキングコードを追加する

GA のデフォルトタグは、次のような基本イベントを追跡します： [ページビュー、セッション、ユーザーなど](https://support.google.com/analytics/answer/9234069?hl=en\&ref_topic=13367566)。ここで行うのは、次のものを作成することです： [**カスタムイベント**](https://support.google.com/analytics/answer/12229021) GA API を使用して。

このカスタムコードでは、次の `adblock_user` 推奨イベントを作成します。追跡したい各ページに追加するコードは次のとおりです：

```html
<script type="text/javascript">var isAdBlockActive=true;</script>
<script src="ad-units.js" type="text/javascript"></script>
<script>
  window.onload = function(e) {
    if(isAdBlockActive){
      gtag("event", "adblock_user", {
        "user":"adblock"
      })
      console.log('Adblock user')
        } else {
      gtag("event", "adblock_user", {
        "user":"standard"
          })
      console.log('Standard user')
    }
  };
</script>
```

このコードを次の後に配置します： `body` トラッキングしたい各ウェブサイトの body タグです。このコードの各部分について詳しく見ていきましょう：

* まず、変数 `isAdblockActive` を `true`と宣言しています。つまり、あなたのウェブサイトを訪れるすべてのユーザーで Adblock が有効になっていることになります。直後に、次の `ad-units.js` 先ほど作成したスクリプトを呼び出し、この変数を `false`に変更します。つまり、次の `ad-units.js` ファイルをブロックするアドブロッカーがない限り、ユーザーは「standard」として扱われます。ブロックされる場合は「adblock」として扱われます。
* 次に、という名前のカスタムイベントを作成します。 `adblock_user` これは、変数 `isAdBlockActive` が true かどうかに基づくイベントです。ここで `user` イベントパラメータを追加したのは、GA 上で素早く識別できるようにするためです。これについては次のセクションで詳しく説明します。

次のものを配置していることを確認してください： [**基本の GA トラッキングコード**](https://support.google.com/analytics/answer/9304153#add-tag\&zippy=%2Cadd-the-google-tag-directly-to-your-web-pages) を `head` タグに入れてください。そうでないとコードは動作しません。
{% endstep %}

{% step %}

## GA でディメンションとカスタムイベントを作成する

この手順により **GA ダッシュボードで Adblock ユーザーをより見やすく把握できます**。 **ディメンション** は各種レポートのフィルターとして使用でき、一方で **カスタムイベント** は、サイト上の Adblock ユーザー数を確認できる特定のページを表示します。

### カスタムディメンション

{% stepper %}
{% step %}
をクリックし、 **管理** > **カスタム定義**をクリックしてから、 **カスタムディメンションを作成**.

![カスタムディメンションの設定 1](/files/f887c75927ad777309834b573016304fb64fa6da)
{% endstep %}

{% step %}
追加 **Adblock** を「ディメンション名」として入力し、 **イベント** を「スコープ」として選択し、任意の説明を追加して、 **user** を「イベントパラメータ」として入力します。

![カスタムディメンションの設定 2](/files/f19c093bb9578c5304d5c6a41183360cbbb066f8)
{% endstep %}

{% step %}
ヒット **保存**.

ディメンションはすぐには機能しません。数日後に十分なイベント／ユーザーを識別すると、レポートに表示され始めます。利用可能になったら、次のように **比較を追加** して、閲覧中のレポートと比較できます：

![カスタムディメンションの比較 1](/files/174d38dcb19fe0b773b4e72437e826dc8f3695cc)

![カスタムディメンションの比較 2](/files/b9af4bf31b985ad779d9c2fca6e02a689fb30d68)
{% endstep %}
{% endstepper %}

### カスタムイベント

{% stepper %}
{% step %}
をクリックし、 **管理** > **イベント**をクリックしてから、 **カスタムイベントを作成**.

![カスタムイベントの設定 1](/files/74456272784672c4e71fc2fb0e2a6ce770c79f48)
{% endstep %}

{% step %}
をクリックし、 **作成**。カスタムイベント名には **adblock\_user**と入力します。次に、照合条件として次の内容を入力します：

![カスタムイベントの設定 1](/files/0c437ecdd57bfc57fad1c2f7d1259e6ce15a477e)
{% endstep %}

{% step %}
最後に、「ソースイベントからパラメータをコピー」を有効にして「保存」をクリックします。

カスタムイベントもすぐには機能しません。数日後に数回発火すると、レポートに表示され始めます。このイベントを選択すると、Adblock ユーザーをより詳細に確認できます。

![カスタムイベントの結果](/files/acbac6e00294741739e706da24d187465f447a21)
{% endstep %}
{% endstepper %}
{% endstep %}
{% endstepper %}


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.exoclick.com/publishers/ja/adblock/track-adblock-users-ga.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
