Socket
Book a DemoInstallSign in
Socket

@gravitywelluk/gtm

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gravitywelluk/gtm

Typed Google Tag Manager helper functions that ensures your app won't crash if GTM is not instantiated.

latest
Source
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

Gravitywell GTM

Typed Google Tag Manager helper functions that ensures your app won't crash if GTM is not instantiated.

CI License Downloads Version


Table of Contents

  • Table of Contents
  • Installation
  • Google GA4 Events

Installation

yarn add @gravitywelluk/gtm

# or

npm install --save @gravitywelluk/gtm

Google GA4 Events

Helper functions to track Google GTM GA4 events.

gtmGa4EventEcommerce()

Tracks a GA4 e-commerce event

import { gtmGa4EventEcommerce } from "@gravitywelluk/gtm";

// Track an add_to_cart event
gtmGa4EventEcommerce("add_to_cart", {
  currency: "GBP",
  value: 215.14,
  items: items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Google Store",
      coupon: "SUMMER_FUN",
      currency: "USD",
      discount: 2.22,
      index: 5,
      item_brand: "Google",
      item_category: "Apparel",
      item_category2: "Adult",
      item_category3: "Shirts",
      item_category4: "Crew",
      item_category5: "Short sleeve",
      item_list_id: "related_products",
      item_list_name: "Related Products",
      item_variant: "green",
      location_id: "L_12345",
      price: 107.57,
      quantity: 2
    }
  ]
});

gtmGa4EventAuth()

Tracks a GA4 authentication event.

import { gtmGa4EventAuth, GtmGa4EventAuthMethod } from "@gravitywelluk/gtm";

gtmGa4EventAuth("login", GtmGa4EventAuthMethod.GITHUB);
gtmGa4EventAuth("sign_up", GtmGa4EventAuthMethod.GOOGLE);

gtmGa4EventShare()

Tracks a GA4 share event.

import { gtmGa4EventShare, GtmGa4EventShareMethod } from "@gravitywelluk/gtm";

gtmGa4EventShare('/example-page', GtmGa4EventShareMethod.TWITTER);

Keywords

gravitywell

FAQs

Package last updated on 20 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts