このガイドでは、完全に自社構築した Web サイト、Headless Mode で運用している Shopify stores、または他の CMS platforms で構築されたサイトなど、custom websites に Mintegral Pixel を連携する方法を説明します。
連携方法は 2 つあります。
どちらの方法でも、page views、user interactions、conversion events をトラッキングできます。
このガイドでは、Method #1 として GTM 経由での連携を説明します。
Use case: Web サイトで GTM を使用して scripts と tracking codes を管理している場合。
Step 1: Mintegral Pixel SDK を読み込む
<script>
(function (w, d) {
var u = "https://cdn-static.mintegral.com/sdk/pixel.js";
if (w.mintegralPixel) return;
var s = (w.mintegralPixel = function () {
s.performOperation
? s.performOperation.apply(s, arguments)
: s.operationQueue.push(arguments);
});
s.operationQueue = [];
var f = d.getElementsByTagName("script")[0],
e = d.createElement("script");
e.async = !0;
e.src = u;
f.parentNode.insertBefore(e, f);
})(window, document);
mintegralPixel("init", {
setupType: 1 // 1 - self-built website
});
</script>
⚠️ Note: 重複 events を避けるため、SDK は各ページで 1 回だけ読み込んでください。
Step 2: Mintegral Official Events をレポートする
Mintegral Event Data Structure
Mintegral にレポートされるすべての events は、以下の標準 data structure に従う必要があります。
| Name | Type | Description |
|---|---|---|
| type | string | event の名前。利用可能な events については Standard Events and Objectsを参照してください。 |
| data | object | event のデータ。送信する data については Standard Events and Objectsを参照してください。 |
以下のコードをコピー&ペーストし、Website 上で Data Layer を準備します。
dataLayer.push({
"event": "purchaseEvent",
"mtg_type": "purchase",
"mtg_data": {
"currency": "USD",
"value": 179.98,
"items": [
{
"item_variant_id": "sku123-blue-42",
"item_id": "sku123",
"item_name": "Air Sneakers",
"price": 89.99,
"quantity": 2,
"image_url": "https://cdn.example.com/images/sku123.jpg"
}
]
}
});
⚠️ Note:
mtg_typeとmtg_dataは Mintegral specifications に準拠している必要があります。
eventは GTM triggers のみに使用され、SDK reporting には影響しません。
GTM Configuration
DLV - MTG Type → mtg_type
DLV - MTG Data → mtg_data
Event name: 例: purchaseEvent
以下のコードをコピー&ペーストし、trigger を割り当てて configuration を公開します。
<script>
mintegralPixel("track", {
"type": "{{DLV - MTG Type}}",
"data": {{DLV - MTG Data}}
});
</script>