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

@voicenter-team/lead-tracker

v1.0.4

Published

LeadTracker is a comprehensive library for managing lead tracking, collecting user data, automating web actions, and generating DIDs to effectively track and manage call leads.

Downloads

752

Readme


title: Getting started navigation: title: Getting Started

Lead Tracker Library

Overview

The LeadTracker library is designed to streamline lead tracking on your website by collecting user information, handling API calls, generating DIDs to track call leads, and automating actions based on specified configurations. This document provides an overview of the library, its installation, usage, and detailed descriptions of its types and methods.

Installation

To install the Lead Tracker Library, simply include the library file in your project:

<script src="https://mirrored-lead-tracker-cdn.pages.dev/lead-tracker.umd.js"></script>

Or, if you're using a module bundler, you can install it via npm:

npm install @voicenter-team/lead-tracker

Usage Example

import LeadTracker, { InitOptions } from '@voicenter-team/lead-tracker';

const defaultOptions: InitOptions = {
    cookiesAllowed: false,
    actions: {
        call: [
            { selector: '.call-me' },
            { selector: '#callMe' },
            { selector: '#callMeMobile', activeMaxWidth: 768 }
        ],
        href: [
            { selector: '.replace-my-href' },
            { selector: '#replaceMyHref' },
            { selector: '#replaceMyHrefMobile', activeMinWidth: 768 }
        ]
    }
};

const leadTracker = new LeadTracker({
    autoRefreshDID: true,
    silent: false,
    token: 'your-api-token'
});

leadTracker.init({ ...defaultOptions }).then(async () => {
    await leadTracker.actionsProceed();
    
    await leadTracker.saveLeadInfo();
    
    document.getElementById('getAllQuery')?.addEventListener('click', async () => {
        const queryParams = await leadTracker.getLeadInfo();
        console.log('Query params:', queryParams);
        alert('Check the console for the query params');
    });
    
    document.getElementById('getDID')?.addEventListener('click', async () => {
        const did = await leadTracker.getDID();
        console.log('DID:', did);
        alert('Check the console for the DID');
    });
    
    document.getElementById('updateOptions')?.addEventListener('click', async () => {
        await leadTracker.proceed({
            cookiesAllowed: true,
            actions: {
                text: [
                    { selector: '.replace-me' },
                    { selector: '#replaceMe' },
                    { selector: '#replaceMeMobile', activeMinWidth: 768, activeMaxWidth: 1024 }
                ]
            }
        });
        alert('Options updated');
    });
    
    document.getElementById('clearOptions')?.addEventListener('click', async () => {
        localStorage.clear();
        await leadTracker.proceed({ ...defaultOptions, baseInfo: { prikoldesc: 'PrikolDesc' } });
        alert('Options cleared');
    });
})

So first, you need to create a new instance of the LeadTracker class with the required options. Then, you can proceed with the initialization by calling the proceed method with the desired options. The LeadTracker, in order to optimize the performance, will not generate DID if it is not required.

API Reference

LeadTracker Class

Constructor

constructor(options: LeadTrackerConfig)
  • options - Configuration options for LeadTracker.

Methods

  • getLeadInfo(): Returns a promise that resolves with an array of query parameters.
  • saveLeadInfo(): Saves collected information via the API handler.
  • getDID(): Returns a promise that resolves with the DID (phone number).
  • init(options: Partial<InitOptions>): Initializes the lead tracker.
  • setOptions(options: Partial<InitOptions>): Updates the options.
  • actionsProceed(): Processes actions.

LeadTracker Types

LeadTrackerConfig

| Property | Type | Default | Description | |------------------|-------------|---------|-------------------------------------------------------------| | token | string | - | The JWT token for the API. | | silent | boolean | true | If set to true, will not log any messages. | | autoRefreshDID | boolean | false | If true, will automatically refresh the DID upon expiration |

InitOptions

| Property | Type | Default | Description | |-------------------|----------|---------|----------------------------------------------------------------------------| | cookiesAllowed | boolean | false | If true, will allow cookies. | | actions | object | - | Actions configuration. Refer to ActionsConfig | | baseInfo | object | - | Additional information to be sent with the API request. Accepts any object |

ActionsConfig

| Property | Type | Default | Description | |----------|----------|---------|------------------------------------------------------------------------------------------------------| | call | object[] | - | Array of objects with selectors for call actions. Refer to SelectorConfig | | href | object[] | - | Array of objects with selectors for href actions. Refer to SelectorConfig | | text | object[] | - | Array of objects with selectors for text actions. Refer to TextSelectorConfig |

SelectorConfig

| Property | Type | Default | Description | |------------------|--------|---------|--------------------------------------------| | selector | string | - | CSS selector for the element. | | activeMinWidth | number | - | Minimum width for the action to be active. | | activeMaxWidth | number | - | Maximum width for the action to be active. |

TextSelectorConfig - extends SelectorConfig

| Property | Type | Default | Description | |----------|--------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | mask | string | - | An optional property that specifies a format mask for the input value. The mask uses # to represent numerical values and any other character will be displayed as-is. For example, a mask of ###-####-##.# applied to the input 12345678901 will format the result as 123-4567-89.01. This is useful for standardizing the appearance of numerical inputs. |

Contributing

Contributions to the Lead Tracker Library are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.

License

The Lead Tracker Library is open-source software licensed under the MIT license.