Démarrage
Copiez un prompt de configuration avec les étapes d'installation et le guide Markdown complet pour ce 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.
Installer
Section intitulée « Installer »bun add @capgo/capacitor-gtmbunx cap syncImporter
Section intitulée « Importer »import { GoogleTagManager } from '@capgo/capacitor-gtm';API Vue d'ensemble
Section intitulée « API Vue d'ensemble »Initialise Google Tag Manager avec l'ID de conteneur spécifié.
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.initialize({} as { containerId: string; timeout?: number });Envoie un événement à la dataLayer du Google Tag Manager.
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.push({ event: 'purchase', parameters: { value: 99.99, currency: 'USD' }});setUserProperty
Section intitulée « setUserProperty »Définit une propriété utilisateur dans la dataLayer du Google Tag Manager.
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.setUserProperty({ key: 'user_type', value: 'premium'});getValue
Section intitulée « getValue »Récupère une valeur de la dataLayer du Google Tag Manager. Recherche dans la dataLayer la valeur la plus récente de la clé spécifiée.
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.getValue({} as { key: string });Réinitialise l'instance du Google Tag Manager et efface toutes les données. Cela supprimera toutes les données de la dataLayer et nécessitera une réinitialisation.
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.reset();Source de Vérité
Section intitulée « Source de Vérité »Cette page est générée à partir du plugin’s src/definitions.tsRe-run the sync when the public API changes upstream.