Getting Started
このプラグインのインストール手順とフルマークダウンガイドのセットアッププロンプトを1つのコピー可能なプロンプトで取得してください。
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.
インストール
「インストール」のセクションCapgoのAIアシストセットアップを使用してプラグインをインストールできます。AIツールにCapgoスキルを追加するには、以下のコマンドを使用してください。
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins次のプロンプトを使用してください。
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-gtm` plugin in my project.Manual Setup を使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。
bun add @capgo/capacitor-gtmbunx cap syncImport
「Import」のセクションimport { GoogleTagManager } from '@capgo/capacitor-gtm';API の概要
「API の概要」のセクションinitialize
「initialize」のセクション指定されたコンテナIDでGoogle Tag Managerを初期化します。
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を実行してください。
続けてGetting Started
「続けてGetting Started」あなたが Getting Started を使用してダッシュボードとAPIの作業を計画している場合、 Using @capgo/capacitor-gtm Using @capgo/capacitor-gtm のネイティブ機能APIの概要 Capgoの実装詳細についてはAPIの概要を参照してください。 概要 Capgoの実装詳細については概要を参照してください。 APIのキー Capgoの実装詳細についてはAPIのキー、 デバイス Capgoの実装詳細についてはデバイスを参照してください。