# @apolitical/gtm

> Browser library to interact with Google Tag Manager (GTM)

Latest version **1.2.4** (published 2026-08-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @apolitical/gtm
pnpm add @apolitical/gtm
yarn add @apolitical/gtm
bun add @apolitical/gtm
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.2.4 |
| Published | 2026-08-29 |
| First published | 2022-04-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=20.14.0 |
| Dependencies | 1 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Apolitical Group Limited |
| Maintainers | npm-apolitical-styleguide |
| Keywords | JavaScript, Library, Template |

## Links

- npm: https://www.npmjs.com/package/@apolitical/gtm
- npm.io page: https://npm.io/package/@apolitical/gtm

## Dependencies (1)

- [react-gtm-module](https://npm.io/package/react-gtm-module.md) 2.0.11

## Recent versions

- 1.2.4 (latest) — 2026-08-29
- 1.2.3 — 2024-12-12
- 1.2.2 — 2023-02-01
- 1.2.1 — 2022-06-30
- 1.2.0 — 2022-05-23
- 1.2.0-rc.1 — 2022-05-19
- 1.1.1 — 2022-05-13
- 1.1.1-rc.1 — 2022-05-13
- 1.1.0 — 2022-05-12
- 1.1.0-rc.2 — 2022-05-11
- 1.1.0-rc.1 — 2022-04-25
- 1.0.1 — 2022-04-08
- 1.0.1-rc.2 — 2022-04-08
- 1.0.1-rc.1 — 2022-04-08
- 1.0.0 — 2022-04-07
- … 3 more at https://npm.io/package/@apolitical/gtm/versions

## README

# Apolitical GTM

Browser library to interact with Google Tag Manager (GTM)

## Requirements

Requires the following to run:

- [node.js][node] 16.13.0+
- [yarn][yarn]

[node]: https://nodejs.org/en/download/
[yarn]: https://classic.yarnpkg.com/en/docs/install

## Installation

Install with `yarn`:

```sh
yarn add @apolitical/gtm
```

## Available Scripts

In the project directory, you can run:
### `yarn run test`

Runs the test (and the interactive mode can be enabled with `--watchAll`).

### `yarn build`

Builds the library for production to the `build` folder.
It correctly bundles the code on production mode and optimizes the build for the best performance.

### `yarn publish`

Publishes the library to NPM.

## Usage

The recommended way to use `@apolitical/gtm` is to set the context with the appropriate parameters:

```js
const { setContext, runExample } = require('@apolitical/gtm');

setContext({ origin: 'some-url' });
```

And then, you can query Contentful as you like:

```js
runExample();
```

## Troubleshooting

### Usage of other libraries within your library

- Add the library as a dependency in `package.json` (effectively requiring the calling project to provide this dependency)
- Add the Contentful library as a dependency in `package.json`. By default, only the library code is published, meaning that the Contentful library needs to be installed separately

---
_Source: https://npm.io/package/@apolitical/gtm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
