はじめに
このプラグインのインストール手順と完全なマークダウンガイドを含むセットアッププロンプトをコピーする
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-gtm`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/gtm/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Install
Section titled “Install”bun add @capgo/capacitor-gtmbunx cap syncImport
Section titled “Import”import { GoogleTagManager } from '@capgo/capacitor-gtm';initialize
Section titled “initialize”Googleタグマネージャーを指定されたコンテナIDで初期化します。
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.initialize({} as { containerId: string; timeout?: number });Google Tag Managerのデータレイヤーにイベントをプッシュします。
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.push({ event: 'purchase', parameters: { value: 99.99, currency: 'USD' }});setUserProperty
Section titled “setUserProperty”Google Tag Managerのデータレイヤーにユーザープロパティを設定します。
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.setUserProperty({ key: 'user_type', value: 'premium'});getValue
Section titled “getValue”Google Tag Managerのデータレイヤーから値を取得します。 データレイヤーを検索して、指定されたキーに対応する最新の値を取得します。
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.getValue({} as { key: string });Google Tag Managerのインスタンスをリセットし、すべてのデータをクリアします。 データレイヤーからすべてのデータを削除し、再初期化が必要になります。
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.reset();真実の源
「真実の源」というセクションこのページはプラグインの src/definitions.ts公開APIがアップストリームで変更されたときに再度syncを実行してください。