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.
npm install @bing-ads/uet-pwa-sdk
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");
Creates an instance of the UET PWA SDK.
-
options
(optional): An object with configuration options.-
ti
(required): Tag ID for the UET events.
-
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.
-
ea
: Event action. -
el
: Event label. -
ec
: Event category. -
gv
: Goal value (number). -
gc
: Goal currency (string).
uet.trackGoal("purchase", "Product XYZ", "ecommerce", 100, "USD");
Retrieves the click ID (if available). This method attempts to retrieve the click details associated with the current session.
uet.getClickId().then(clickId => {
console.log(clickId);
});
const clickId = await uet.getClickId();
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.