@bing-ads/uet-pwa-sdk
v1.1.0
Published
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`.
Downloads
4,750
Readme
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.