Getting Started
Copy a setup prompt with the install steps and the full markdown guide for this plugin.
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.
Ce contenu n'est pas encore disponible dans votre langue.
Install
Section titled “Install”bun add @capgo/capacitor-gtmbunx cap syncImport
Section titled “Import”import { GoogleTagManager } from '@capgo/capacitor-gtm';API Overview
Section titled “API Overview”initialize
Section titled “initialize”Initializes Google Tag Manager with the specified container ID.
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.initialize({} as { containerId: string; timeout?: number });Pushes an event to the Google Tag Manager dataLayer.
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.push({ event: 'purchase', parameters: { value: 99.99, currency: 'USD' }});setUserProperty
Section titled “setUserProperty”Sets a user property in the Google Tag Manager dataLayer.
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.setUserProperty({ key: 'user_type', value: 'premium'});getValue
Section titled “getValue”Gets a value from the Google Tag Manager dataLayer. Searches through the dataLayer for the most recent value of the specified key.
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.getValue({} as { key: string });Resets the Google Tag Manager instance and clears all data. This will remove all data from the dataLayer and require re-initialization.
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.reset();Source Of Truth
Section titled “Source Of Truth”This page is generated from the plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.