@bing-ads/uet-pwa-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

UET PWA SDK

Welcome to the UET PWA SDK project! This SDK facilitates the tracking of events in a Progressive Web App (PWA) and sends Universal Event Tracking (UET) events to Bing Ads by making HTTP requests to bat.bing.com.

To learn more about Universal Event Tracking, visit Microsoft Advertising - Universal Event Tracking.

Usage

Installation

npm install @bing-ads/uet-pwa-sdk

Example

import UETPWASDK from '@bing-ads/uet-pwa-sdk';

// Initialize the UET PWA SDK
const uet = new UETPWASDK({ ti: "<tag_id>" });

// Track a goal
uet.trackGoal("purchase", "Product XYZ", "ecommerce", 100, "USD");

UETPWASDK Class

constructor(options: UETPWASDKOptions)

Creates an instance of the UET PWA SDK.

Parameters

  • options (optional): An object with configuration options.
    • ti (required): Tag ID for the UET events.

Example

const uet = new UETPWASDK({ ti: "<tag_id>" });

trackGoal(ea: string, el: string, ec: string, gv: number, gc: string): Promise<Response | undefined>

Tracks a goal by sending a custom event to Bing Ads.

Parameters

  • ea: Event action.
  • el: Event label.
  • ec: Event category.
  • gv: Goal value (number).
  • gc: Goal currency (string).

Example

uet.trackGoal("purchase", "Product XYZ", "ecommerce", 100, "USD");

getClickId(): Promise<string>

Retrieves the click ID (if available). This method attempts to retrieve the click details associated with the current session.

Example

uet.getClickId().then(clickId => {
  console.log(clickId);
});

const clickId = await uet.getClickId();

Automatic Launch Event

Upon instantiation of UETPWASDK class, automatically triggers an event call. This method sends an event with the action activation on the first app launch and launch for subsequent launches.

Readme

Keywords

none

Package Sidebar

Install

npm i @bing-ads/uet-pwa-sdk

Weekly Downloads

259

Version

1.1.0

License

none

Unpacked Size

17.7 kB

Total Files

6

Last publish

Collaborators

  • conantonakos