Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vivareal/gtm-tracker

Package Overview
Dependencies
Maintainers
118
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vivareal/gtm-tracker

GTM Tracker with clickstream helper

  • 1.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
102
decreased by-38.55%
Maintainers
118
Weekly downloads
 
Created
Source

@vivareal/gtm-tracker

Tracker to populate the GTM dataLayer and add clickstream global method

Usage

// ../gtm-tracker.js
import { GtmTracker } from '@vivareal/gtm-tracker';

export default new GtmTracker({
  id: 'GTM-XXXXX',
  dataLayerName: 'dataLayerClickstream',
  trackerEndpoint: '', // clickstream URL
  enabled: true,
  debug: false,
});

Options

OptiondefaultDesc
idnullGTM Id
dataLayerNamedataLayerClickstreamsame name as you used when importing the GTM plugin
trackerEndpoint''Your tracking server endpoint
enabledtrueStart enabled/disabled
debugfalseDebug enabled

Install as a Vue plugin

import Vue from 'vue';
import { VueGtm } from '@vivareal/gtm-tracker';
import tracker from './gtm-tracker';

Vue.use(VueGtm, { tracker });

This will enable in your project to use the tracker directly in components in a "Vue-way"

// App.js
export default {
  watch: {
    // If using vue-router
    $route(to) {
      this.$gtm.pageView(to);
    },
  },
};

Please note that you don't need to add it as a plugin, you can simply import the tracker directly in components, and use it, but this removes the need to import it in every component that you want to track something

Methods

MethodDesc
trackEvent(Obj)Object to populate dataLayer, it demands a event key
pageView(Obj)Will populate dataLayer with an object containing { event: 'pageRendered' }
pushDataLayer(Obj)Directly input any object into the dataLayer
enable(Boolean)Enable or disable tracking
debug(Boolean)Enable or disable debugging
dataLayer()Retrieves current dataLayer array

FAQs

Package last updated on 07 Jun 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc