@gotipath/analytics

0.1.10 • Public • Published

Tracker - GotipathAnalytics

This is the web client used to track page and media events of websites for the Gotipath Analytics.

Installation

Install the package using npm or yarn:

npm i @gotipath/analytics
or
yarn add @gotipath/analytics

Usage

Follow the steps below to use the package.

React/Next.js

// layout.tsx
import { initTracking } from '@gotipath/analytics';

initTracking({
    trackingUrl: 'http://<organization>.analytics.gotipath.com/tracking/v1/<project-id>/<platform-id>',
    debugMode: true,
});

Media tracking is done by adding the following code to the player component:

// player.tsx
import { addPlayer, removePlayer } from '@gotipath/analytics/media';
import { useEffect, useRef } from 'react';

export function YourPlayer({ video }: Props) {
    const playerRef = useRef(null);

    useEffect(() => {
        if (!playerRef.current) return;
        const analPlayer = addPlayer(playerRef.current);

        return () => {
            removePlayer(analPlayer);
        };
    }, [playerRef.current]);

    return (
        <>
            <video
                ref={playerRef}
                width="800"
                height="450"
                data-media-id={video.id}
                data-media-type="movies"
                title={video.title}
                src={video.src}
                poster={video.poster}
                controls
                autoPlay
            ></video>
        </>
    );
}

Package Sidebar

Install

npm i @gotipath/analytics

Weekly Downloads

222

Version

0.1.10

License

ISC

Unpacked Size

244 kB

Total Files

180

Last publish

Collaborators

  • gotipath