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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mtr-pixel

v1.1.0

Published

Validação de fluxo e conversões geradas pelos agents

Readme

MTR-Pixel

Description

MTR-Pixel is a library designed for tracking user interactions and conversions on websites. The library sends tracking events to a specified backend endpoint.

Install

  1. Clone the repository:

    git clone https://github.com/morethanrealio/mtr-pixel.git
    cd mtr-pixel
  2. Install dependencies:

    npm install
  3. Build or develop:

    npm run-script build

    This command will compile the TypeScript code and generate the mtr_pixel.js file in the dist directory. If you want to develop, you'll need to run the following command:

    npm run-script watch

    This command will compile and watch for changes in the TypeScript code and generate the mtr_pixel.js file in the dist directory.

Usage

To integrate MTR-Pixel into your website, include the generated mtr_pixel.js file in your HTML and initialize the MTRPixel class.

  1. Include the script in your HTML:

    <script src="path/to/dist/mtr_pixel.js"></script>
  2. Initialize the MTRPixel class:

    The MTRPixel class is automatically initialized when the script loads, but it requires specific URL parameters to be present: mtrsessionid, mtruserid, and mtrtimestampstart to track specific users.

    Here's an example of how you can structure your URL:

    https://yourwebsite.com/?mtrsessionid=SESSION_ID&mtruserid=USER_ID&mtrtimestampstart=TIMESTAMP
  3. Track events:

    Once the MTRPixel is initialized, you can track events using the trackEvent method. This method accepts an object with any custom data you want to send. To track user actions use the CTA parameter.

    // Initialize MTRPixel
    const mtrPixel = new MTRPixel();
    
    // Track an user action on load
    mtrPixel.trackEvent({CTA: "Carregar Loja"});
    
    // Track a button click event
    document.getElementById('myButton').addEventListener('click', () => {
        mtrPixel.trackEvent({CTA: 'Comprar'});
    });

Example

Here is a complete example of how to use MTR-Pixel in an HTML file:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MTR-Pixel Demo</title>
    <script src="dist/mtr_pixel.js"></script>
</head>
<body>

    <h1>MTR-Pixel Demo</h1>
    <button id="start" onclick="start()">Start</button>
    <div id="mtr-div" style="display: none">
        <p>Check the console to see the tracking events.</p>
        <button id="trackButton">Track Event</button>
    </div>

    <script>
        // Ensure URL parameters are present for initialization
        // Example: https://yourwebsite.com/?mtrsessionid=123&mtruserid=456&mtrtimestampstart=2023-01-01T00:00:00Z

        function start() {
            // simulation of getting the IDs of the user by URL parameters
            const sessionId = "7d498726-2ccd-4316-b447-2e8a9e06a7f7";
            const userId = "6c257aff-e173-4020-ae12-1a3596122cde";
            const timestampStart = "2025-11-11T19:52:48.995Z";
            window.location.assign(`${window.location.href}?mtrsessionid=${sessionId}&mtruserid=${userId}&mtrtimestampstart=${timestampStart}`);
        }

        // check if the website is already started with session id and user id
        const urlParams = new URLSearchParams(window.location.search);
        const sessionId = urlParams.get("mtrsessionid");
        const userId = urlParams.get("mtruserid");
        const timestampStart = urlParams.get("mtrtimestampstart");
        if (sessionId && userId && timestampStart) {
            // hide start button
            document.getElementById("start").style.display = "none";
            // show test div
            document.getElementById("mtr-div").style.display = "block";

            // initialize mtr-pixel
            const mtrPixel = new MTRPixel();

            // track a page view event on load
            mtrPixel.trackEvent({CTA: "Carregar Loja"});

            // add a click event listener to the button
            document.getElementById('trackButton').addEventListener('click', () => {
                mtrPixel.trackEvent({CTA: 'Comprar'});
            });
        }
    </script>
</body>
</html>

For more details, you can refer to the demo available in the demos/website directory.