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

alpp-tracker.js

v1.2.1

Published

Alpp tracker

Downloads

6

Readme

alpp-tracker

A simple tracker in JavaScript to upload events directly from the browser to Alpp.

How it works

The tracker helps you record events in your HTML page and stores them in a Data Source within your Alpp account.

By default, the tracker stores along every event basic fields like:

  • timestamp (DateTime) of the event
  • session_id (String) an automatically generated uuid to track a given user session through different pages for 30 min
  • event (String) with a name that can be passed on instantiation to better split events
  • hostname (String) the hostname of the page
  • source (Object) the source of the user
  • user_id (String) . an automatically generated uuid to track a given user for 90 days

Additionally, as part of every event, you can pass along any attribute in JSON format.

Getting Started

Data Source schema

The schema is the set of columns, their types and their jsonpaths, that you want to store in a Data Source. In this case, the schema will contain the set of default properties plus the extra data you want to send with every event.

For instance, let's say you want to send an id of the element that triggered the event, the user email and the section of your application where the event happened.

alpp('click', {
  id: 'buy-button',
  userEmail: '[email protected]',
  section: 'shopping cart'
})

Instantiating the script

Place this code snippet in your HTML file, adding the secure append token you've just created and the Data Source name.

<script data-token="YOUR_TOKEN" src="https://cdn.jsdelivr.net/npm/alpp-tracker.js" defer></script>

Issuing events

Once the script is loaded in the DOM, you can start sending events with the alpp object. It accepts two parameters, the first one is the event name, and the second one, the rest of the attributes you want to store.

This is an example of storing a pageload event which will be triggered once the script is loaded:

<script>
  alpp('pageload', { referrer: document.referrer, page: 'landing_page_1' })
</script>

The following would be an example to trigger "onclick":

alpp('click', {
  referrer: document.referrer,
  page: 'landing_page_1',
  place: 'sign-up button'
})

If you want to initialize the alpp object with events before the script is loaded and ready, you can add as many tuple events as in an Array:

<script>
  window.alpp = [
    ['event_name', { hey: 'hello' }],
    ['click', { place: 'image' }]
  ]
</script>