{"id":31433419,"url":"https://github.com/cap-go/capacitor-gtm","last_synced_at":"2026-04-27T09:03:06.626Z","repository":{"id":307229754,"uuid":"1028781015","full_name":"Cap-go/capacitor-gtm","owner":"Cap-go","description":"Capacitor plugin to use google tag manager (GMT) natively","archived":false,"fork":false,"pushed_at":"2026-01-10T18:04:41.000Z","size":599,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-11T00:25:24.964Z","etag":null,"topics":["capacitor","gmt","ionic","plugin"],"latest_commit_sha":null,"homepage":"https://capgo.app","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cap-go.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"Cap-go","patreon":null,"open_collective":"capgo","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2025-07-30T04:03:27.000Z","updated_at":"2026-01-05T14:23:40.000Z","dependencies_parsed_at":"2025-10-16T12:46:26.331Z","dependency_job_id":"8c2749f5-3c02-448e-ad57-ca853cb52dc3","html_url":"https://github.com/Cap-go/capacitor-gtm","commit_stats":null,"previous_names":["riderx/capactior-gtm","cap-go/capacitor-gtm"],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/Cap-go/capacitor-gtm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-gtm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-gtm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-gtm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-gtm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cap-go","download_url":"https://codeload.github.com/Cap-go/capacitor-gtm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-gtm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28780019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T13:55:28.044Z","status":"ssl_error","status_checked_at":"2026-01-26T13:55:26.068Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["capacitor","gmt","ionic","plugin"],"created_at":"2025-09-30T11:14:34.151Z","updated_at":"2026-04-27T09:03:06.616Z","avatar_url":"https://github.com/Cap-go.png","language":"Swift","funding_links":["https://github.com/sponsors/Cap-go","https://opencollective.com/capgo"],"categories":[],"sub_categories":[],"readme":"# Capacitor Google Tag Manager Plugin\n\nA Capacitor plugin for integrating Google Tag Manager into your mobile applications.\n\n\u003e **Note**: This plugin uses the official Google Tag Manager SDK directly for both iOS and Android platforms.\n\n## Documentation\n\nThe most complete doc is available here: https://capgo.app/docs/plugins/gtm/\n\n## Compatibility\n\n| Plugin version | Capacitor compatibility | Maintained |\n| -------------- | ----------------------- | ---------- |\n| v8.\\*.\\*       | v8.\\*.\\*                | ✅          |\n| v7.\\*.\\*       | v7.\\*.\\*                | On demand   |\n| v6.\\*.\\*       | v6.\\*.\\*                | ❌          |\n| v5.\\*.\\*       | v5.\\*.\\*                | ❌          |\n\n\u003e **Note:** The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.\n\n## Installation\n\n```bash\nnpm install @capgo/capacitor-gtm\nnpx cap sync\n```\n\n## Platform Setup\n\n### iOS Setup\n\n1. **Add GTM container file**\n   - Download your container from Google Tag Manager console (GTM-XXXXXX.json)\n   - In Xcode, add the file to your project\n   - Make sure to add it to your app target\n\n### Android Setup\n\n1. **Add GTM container file**\n   - Download the Android default container from Google Tag Manager\n   - Add it as a raw resource in `android/app/src/main/res/raw/`\n   - Rename the file if needed so it uses only lowercase letters, digits, and underscores\n   - The plugin resolves the resource name from your container ID, for example `GTM-ABCD12` becomes `res/raw/gtm_abcd12`\n   - If you use JSON instead of the downloaded binary, it must be a simple default-container JSON. Full GTM export JSON files are not supported by the Android SDK\n\n## API\n\n\u003cdocgen-index\u003e\n\n* [`initialize(...)`](#initialize)\n* [`push(...)`](#push)\n* [`setUserProperty(...)`](#setuserproperty)\n* [`getValue(...)`](#getvalue)\n* [`reset()`](#reset)\n* [`getPluginVersion()`](#getpluginversion)\n* [Type Aliases](#type-aliases)\n\n\u003c/docgen-index\u003e\n\n\u003cdocgen-api\u003e\n\u003c!--Update the source file JSDoc comments and rerun docgen to update the docs below--\u003e\n\nThe main interface for the Google Tag Manager plugin.\n\n### initialize(...)\n\n```typescript\ninitialize(options: { containerId: string; timeout?: number; }) =\u003e Promise\u003cvoid\u003e\n```\n\nInitializes Google Tag Manager with the specified container ID.\n\n| Param         | Type                                                    | Description                   |\n| ------------- | ------------------------------------------------------- | ----------------------------- |\n| **`options`** | \u003ccode\u003e{ containerId: string; timeout?: number; }\u003c/code\u003e | - The initialization options. |\n\n**Since:** 1.0.0\n\n--------------------\n\n\n### push(...)\n\n```typescript\npush(options: { event: string; parameters?: Record\u003cstring, any\u003e; }) =\u003e Promise\u003cvoid\u003e\n```\n\nPushes an event to the Google Tag Manager dataLayer.\n\n| Param         | Type                                                                                          | Description          |\n| ------------- | --------------------------------------------------------------------------------------------- | -------------------- |\n| **`options`** | \u003ccode\u003e{ event: string; parameters?: \u003ca href=\"#record\"\u003eRecord\u003c/a\u003e\u0026lt;string, any\u0026gt;; }\u003c/code\u003e | - The event options. |\n\n**Since:** 1.0.0\n\n--------------------\n\n\n### setUserProperty(...)\n\n```typescript\nsetUserProperty(options: { key: string; value: string | number | boolean; }) =\u003e Promise\u003cvoid\u003e\n```\n\nSets a user property in the Google Tag Manager dataLayer.\n\n| Param         | Type                                                              | Description                  |\n| ------------- | ----------------------------------------------------------------- | ---------------------------- |\n| **`options`** | \u003ccode\u003e{ key: string; value: string \\| number \\| boolean; }\u003c/code\u003e | - The user property options. |\n\n**Since:** 1.0.0\n\n--------------------\n\n\n### getValue(...)\n\n```typescript\ngetValue(options: { key: string; }) =\u003e Promise\u003c{ value: any; }\u003e\n```\n\nGets a value from the Google Tag Manager dataLayer.\nSearches through the dataLayer for the most recent value of the specified key.\n\n| Param         | Type                          | Description                           |\n| ------------- | ----------------------------- | ------------------------------------- |\n| **`options`** | \u003ccode\u003e{ key: string; }\u003c/code\u003e | - The options for retrieving a value. |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;{ value: any; }\u0026gt;\u003c/code\u003e\n\n**Since:** 1.0.0\n\n--------------------\n\n\n### reset()\n\n```typescript\nreset() =\u003e Promise\u003cvoid\u003e\n```\n\nResets the Google Tag Manager instance and clears all data.\nThis will remove all data from the dataLayer and require re-initialization.\n\n**Since:** 1.0.0\n\n--------------------\n\n\n### getPluginVersion()\n\n```typescript\ngetPluginVersion() =\u003e Promise\u003c{ version: string; }\u003e\n```\n\nGet the native Capacitor plugin version\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;{ version: string; }\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### Type Aliases\n\n\n#### Record\n\nConstruct a type with a set of properties K of type T\n\n\u003ccode\u003e{\r [P in K]: T;\r }\u003c/code\u003e\n\n\u003c/docgen-api\u003e\n\n## Usage Example\n\n```typescript\nimport { GoogleTagManager } from '@capgo/capacitor-gtm';\n\n// Initialize GTM\nawait GoogleTagManager.initialize({ \n  containerId: 'GTM-XXXXXX',\n  timeout: 2000 // optional, defaults to 2000ms\n});\n\n// Track an event\nawait GoogleTagManager.push({\n  event: 'purchase',\n  parameters: {\n    value: 29.99,\n    currency: 'USD',\n    items: ['item1', 'item2']\n  }\n});\n\n// Set user property\nawait GoogleTagManager.setUserProperty({\n  key: 'user_type',\n  value: 'premium'\n});\n\n// Get a value from container\nconst result = await GoogleTagManager.getValue({ key: 'api_key' });\nconsole.log('API Key:', result.value);\n\n// Reset data layer\nawait GoogleTagManager.reset();\n```\n\n## Common Use Cases\n\n### E-commerce Tracking\n\n```typescript\n// Track product view\nawait GoogleTagManager.push({\n  event: 'view_item',\n  parameters: {\n    currency: 'USD',\n    value: 15.99,\n    items: [{\n      item_id: 'SKU123',\n      item_name: 'Product Name',\n      price: 15.99,\n      quantity: 1\n    }]\n  }\n});\n\n// Track purchase\nawait GoogleTagManager.push({\n  event: 'purchase',\n  parameters: {\n    transaction_id: '12345',\n    value: 45.99,\n    currency: 'USD',\n    items: [{\n      item_id: 'SKU123',\n      item_name: 'Product Name',\n      price: 15.99,\n      quantity: 2\n    }]\n  }\n});\n```\n\n### User Engagement\n\n```typescript\n// Track screen view\nawait GoogleTagManager.push({\n  event: 'screen_view',\n  parameters: {\n    screen_name: 'Home',\n    screen_class: 'HomeViewController'\n  }\n});\n\n// Track custom event\nawait GoogleTagManager.push({\n  event: 'level_complete',\n  parameters: {\n    level: 5,\n    score: 1000,\n    time_spent: 300\n  }\n});\n```\n\n## Troubleshooting\n\n### iOS Issues\n\n1. **Container not loading**: Ensure the GTM container JSON file is properly added to your Xcode project and included in the app bundle.\n\n2. **Build errors**: Make sure you've run `npx cap sync` after installation.\n\n### Android Issues\n\n1. **Container not found**: Verify the default container is available under `android/app/src/main/res/raw/` with a filename like `gtm_xxxxxx.json` or `gtm_xxxxxx.bin`. The resource name (filename without the extension) must match your container ID after lowercasing and replacing `-` with `_`.\n\n2. **Initialization failures**: Check that the container ID matches your GTM container exactly.\n\n### General Issues\n\n1. **Events not appearing in GTM**: Remember that GTM has a delay in showing real-time events. Also ensure your GTM container is published.\n\n2. **Values returning null**: Make sure the keys exist in your GTM container configuration.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap-go%2Fcapacitor-gtm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcap-go%2Fcapacitor-gtm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap-go%2Fcapacitor-gtm/lists"}