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

@s-ui/tealium-tracker

v1.0.2

Published

Tool to track tealium tags and handle events with tealium

Downloads

298

Readme

@s-ui/tealium-tracker

Tool to track events like click or change and, if a tag is present on the element dispatch a link event to tealium.

This tool is meant to be used with the @s-ui/html-tagger tool but you can define your own tags and it will work asswell.

Use:

Basic usage:

To use it require it from the desired file as this:

require('@s-ui/tealium-tracker').tealiumTracker()

you can use it in a ES6 way too:

import { tealiumTracker } from '@s-ui/tealium-tracker'
tealiumTracker()

The package will:

1. Init listeners:

This will add a document listener watching for:

    1. click event
    1. input change event

Once we click on any 'A', 'BUTTON', 'DIV', 'INPUT', 'SVG' the listener callback will act and check if we or any of our parents with that whitelisted types have the tag data-tealium-tag

If the tag exists it will call a throttle function that will call utag.link function. If there's no utag present on the site the package will warn you with a console message.

Custom event dispatcher usage:

require('@s-ui/tealium-tracker').tealiumTracker({ customEventName: 'MyCustomEventName' })

you can do it in a ES6 way:

import { tealiumTracker } from '@s-ui/tealium-tracker'
tealiumTracker({ customEventName: 'MyCustomEventName' })

The package will:

1. Init listeners:

This will add a document listener watching for:

    1. click event
    1. input change event
    1. customEvent trigger

Once we click on any 'A', 'BUTTON', 'DIV', 'INPUT', 'SVG' the listener callback will act and check if we or any of our parents with that whitelisted types have the tag data-tealium-tag

If the tag exists it will call a throttle function that will call utag.link function. If there's no utag present on the site the package will warn you with a console message.

2. Populate window.dispatchCustomEvent function

For retro-compatibility reasons we populate this function to the window so the sites could dispatch their own custom event without problem.

    window.dispatchCustomEvent = (detail) => dispatchEvent({ eventName: this.customEventName, detail })

Anchor delay use case

Some trackers like xiti inject an image in our site with the purpose of do the track effective. If we made a native redirection we could fall on image load cancelations due the redirection of the page. To avoid that you can init the tracker in a anchorDelay mode that will add the anchor as a callback of our link call and delay the location.reload for ensure purposes.

require('@s-ui/tealium-tracker')({ handleAnchorDelay: true })

you can do it in an ES6 way:

import { tealiumTracker } from '@s-ui/tealium-tracker'
tealiumTracker({ handleAnchorDelay: true })

You can use it both with the custom event

require('@s-ui/tealium-tracker')({ handleAnchorDelay: true, customEventName: 'MyCustomEventName' })

you can do it in an ES6 way:

import { tealiumTracker } from '@s-ui/tealium-tracker'
tealiumTracker({ handleAnchorDelay: true, customEventName: 'MyCustomEventName' })