{"id":23666631,"url":"https://github.com/redsift/js-lib-google-tag-manager","last_synced_at":"2026-01-27T04:06:46.873Z","repository":{"id":145311440,"uuid":"167025863","full_name":"redsift/js-lib-google-tag-manager","owner":"redsift","description":"Helper library to setup Google Tag Manager.","archived":false,"fork":false,"pushed_at":"2024-02-03T06:02:15.000Z","size":177,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-21T00:13:39.974Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/redsift.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2019-01-22T16:18:35.000Z","updated_at":"2019-01-23T13:06:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"6703c044-588a-41c1-bcbe-26502e65f767","html_url":"https://github.com/redsift/js-lib-google-tag-manager","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/redsift/js-lib-google-tag-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redsift%2Fjs-lib-google-tag-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redsift%2Fjs-lib-google-tag-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redsift%2Fjs-lib-google-tag-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redsift%2Fjs-lib-google-tag-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redsift","download_url":"https://codeload.github.com/redsift/js-lib-google-tag-manager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redsift%2Fjs-lib-google-tag-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28801079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T03:44:14.111Z","status":"ssl_error","status_checked_at":"2026-01-27T03:43:33.507Z","response_time":168,"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":[],"created_at":"2024-12-29T07:33:21.697Z","updated_at":"2026-01-27T04:06:46.868Z","avatar_url":"https://github.com/redsift.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-lib-google-tag-manager\n\n`js-lib-google-tag-manager` is a helper library to setup Google Tag Manager. Depending on a cookies flag it propagates a `cookiesConsentYes` or `cookiesConsentNo` custom event to the tag manager, which can be used in your setup to trigger tags depending on the users cookies consent choice. Additionally, a `sendCustomEvent` is provided as part of this library to send a custom event to the tag manager.\n\nYou don't need to include the tag manager script in your HTML, it gets injected by this library.\n\n### Usage\n\n#### Cookies consent given\n\nThis code snippet will setup Google Tag Manager and send a `cookiesConsentYes` custom event which can be used to trigger tags in the configuration UI:\n\n```javascript\nimport setupGoogleTagManager from '@redsift/js-lib-google-tag-manager';\n\nconst config = {\n    id: 'GTAG-CONTAINER-ID',\n    cookiesAllowed: true,\n};\n```\n\n#### No cookies consent given\n\nThis code snippet will setup Google Tag Manager and send a `cookiesConsentNo` custom event which can be used to trigger tags in the configuration UI:\n\n```javascript\nimport setupGoogleTagManager from '@redsift/js-lib-google-tag-manager';\n\nconst config = {\n    id: 'GTAG-CONTAINER-ID',\n    cookiesAllowed: false,\n};\n```\n\n#### Send a custom event\n\nThis code snippet sends a custom event to Google Tag Manager. It can be used e.g. to propagate a button click. It mimics the signature of a Google Analytics event, with `category`, `action`, label` and `value` as parameters:\n\n```javascript\nimport { sendCustomEvent } from '@redsift/js-lib-google-tag-manager';\n\nsendCustomEvent({\n    category: 'cta-clicked',\n    action: 'signup',\n    label: '/pricing',\n    value: 1,\n});\n```\n\n#### Helper functions\n\nTo store the cookies consent flag to localStorage use this:\n\n```\nimport { setCookieConsent } from '@redsift/js-lib-google-tag-manager';\n\nsetCookiesConsent(true);\n```\n\nTo read the flag use:\n\n```\nimport { getCookieConsent } from '@redsift/js-lib-google-tag-manager';\n\nconst gaveConsent = getCookiesConsent();\n```\n\nThe key used to store the flag in localStorage is `redsift/gave-cookie-consent`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredsift%2Fjs-lib-google-tag-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredsift%2Fjs-lib-google-tag-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredsift%2Fjs-lib-google-tag-manager/lists"}