Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including insert-analytics-elements with all npm packages installed. Try it out:

var insertAnalyticsElements = require("insert-analytics-elements")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

insert-analytics-elements v0.0.4

Easily insert analytics elements into the DOM

insert-analytics-elements

Build Status npm version

A small utility library to programmatically insert analytics elements into the DOM.

Installation

# npm
npm i insert-analytics-elements
# yarn
yarn add insert-analytics-elements

Included Providers

Usage

Google Analytics

// JavaScript
const googleAnalytics = require('insert-analytics-elements/googleAnalytics');
googleAnalytics.insertAnalyticsElements('UA-XXXXX-X')

// TypeScript
import { insertAnalyticsElements } from 'insert-analytics-elements/googleAnalytics';
insertAnalyticsElements('UA-XXXXX-X');

Google Analytics with Async

// JavaScript
const googleAnalyticsAsync = require('insert-analytics-elements/googleAnalytics/async');
googleAnalyticsAsync.insertAnalyticsElements('UA-XXXXX-X')

// TypeScript
import { insertAnalyticsElements } from 'insert-analytics-elements/googleAnalytics/async';
insertAnalyticsElements('UA-XXXXX-X');

Google Analytics with gtag

// JavaScript
const googleAnalyticsGtag = require('insert-analytics-elements/googleAnalytics/gtag');
googleAnalyticsGtag.insertAnalyticsElements('UA-XXXXX-X')

// TypeScript
import { insertAnalyticsElements } from 'insert-analytics-elements/googleAnalytics/gtag';
insertAnalyticsElements('UA-XXXXX-X');

Google Tag Manager

// JavaScript
const googleTagManager = require('insert-analytics-elements/googleTagManager');
googleTagManager.insertAnalyticsElements('GTM-XXXX')

// TypeScript
import { insertAnalyticsElements } from 'insert-analytics-elements/googleTagManager';
insertAnalyticsElements('GTM-XXXX');
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free