Getting Started
复制一个包含安装步骤和本插件的完整Markdown指南的设置命令。
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.
bun add @capgo/capacitor-gtmbunx cap sync导入
导入import { GoogleTagManager } from '@capgo/capacitor-gtm';initialize
使用指定的容器ID初始化Google Tag Manager。复制到剪贴板
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.initialize({} as { containerId: string; timeout?: number });复制到剪贴板
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. 当 upstream 的公共 API 变化时,请重新同步。
继续 Getting Started
标题为“继续 Getting Started”如果您正在使用 Getting Started 来规划仪表板和 API 操作,请将其连接到 使用 @capgo/capacitor-gtm 为 Using @capgo/capacitor-gtm 中的原生功能 API Overview 为 API Overview 中的实现细节 介绍 为介绍中实现细节 API 键 为 API 键的实现细节提供密钥,并 设备 为设备的实现细节提供密钥。