npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-tag-manager

v1.0.1

Published

Google Tag Manager plugin for analytics tracking with support for events and pageviews.

Downloads

15

Readme

Tag Manager


Tag Manager plugin for Android and iOS. It allows you to post usage information to your Google Tag Manager account.

This plugin defines a global TagManager Constructor.

Although in the global scope, it is not available until after the deviceready event.

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    console.log(TagManager);
}

When being used in combination with AngularJS, it is recommended to use Angulartics with the Cordova GTM plugin (angulartics-gtm-cordova).

Installation

cordova plugin add com.jareddickson.cordova.tag-manager

Supported Platforms

  • Android
  • iOS

TagManager

var tagManager = cordova.require('com.jareddickson.cordova.tag-manager.TagManager');

Methods

  • tagManager.init: Initialize Tag Manager with an account ID and the number of seconds between dispatching analytics.

  • tagManager.trackEvent: Log an event.

  • tagManager.trackPage: Log a page view.

  • tagManager.dispatch: Force an immediate dispatch to Tag Manager.

  • tagManager.exit: Exit the TagManager instance and stop setInterval.

tagManager.init

Initialize Tag Manager with an account ID and the number of seconds between dispatching analytics.

tagManager.init(success, error, id, [period]);

Parameters

  • success: (Optional) The callback to execute if successful.

  • error: (Optional) The callback to execute if an error occurs.

  • id: The GTM account ID of the form 'GTM-000000'.

  • period: The interval for sending tracking events if any exist in the queue.

Quick Example

// Tag Manager
var tagManager = cordova.require('com.jareddickson.cordova.tag-manager.TagManager');
var trackingId = 'GTM-000000';
var intervalPeriod = 30; // seconds

// Initialize Tag Manager
tagManager.init(null, null, trackingId, intervalPeriod);

tagManager.trackEvent

Log an event.

tagManager.trackEvent(success, error, category, eventAction, eventLabel, eventValue);

Parameters

  • success: (Optional) The callback to execute if successful.

  • error: (Optional) The callback to execute if an error occurs.

  • category: The event category. This parameter is required to be non-empty.

  • eventAction: The event action. This parameter is required to be non-empty.

  • eventLabel: The event label. This parameter may be a blank string to indicate no label.

  • eventValue: (Optional) The event value. This parameter may be -1 to indicate no value. Only accepts digits.

Quick Example

// Track a click-to-call event
tagManager.trackEvent(null, null, 'Link', 'Click', 'Call (800) 123-1234', -1);

tagManager.trackPage

Log a page view.

tagManager.trackPage(success, error, pageURL);

Parameters

  • success: (Optional) The callback to execute if successful.

  • error: (Optional) The callback to execute if an error occurs.

  • pageURL: The URL of the page view.

Quick Example

// Track a pageview on a Contact Us page
tagManager.trackPage(null, null, '/contact-us');

tagManager.dispatch

Force an immediate dispatch to Tag Manager.

tagManager.dispatch([success], [error]);

Parameters

  • success: (Optional) The callback to execute if successful.

  • error: (Optional) The callback to execute if an error occurs.

Quick Example

// Dispatch
tagManager.dispatch();

tagManager.exit

Exit the TagManager instance and stop setInterval.

tagManager.exit([success], [error]);

Parameters

  • success: (Optional) The callback to execute if successful.

  • error: (Optional) The callback to execute if an error occurs.

Quick Example

// Exit
tagManager.exit();

License

The MIT License

Copyright (c) 2014 Jared Dickson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.