@bing-ads/uet-pwa-sdk
v1.0.2
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,570
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
Acquisition Info API for Attribution
⚠️ Origin Trial (OT) token is required in order to access Acquisition Info API for attribution. This token will need to be updated every 6 weeks until the trial is over. We will announce on this page when the trial is done.
Setting Up Origin Trials Token
Origin Trials provide a mechanism for developers to test new features and give feedback to the web standards community on their usability and effectiveness in real-world websites and applications.
To set up an Origin Trials token for your website, follow these steps:
Visit the Origin Trials dashboard for Microsoft Edge: https://microsoftedge.github.io/MSEdgeExplainers/origin-trials/.
Complete form. Register your origin, which is the domain where you plan to test the experimental feature.
Token will be sent to registered email address in ~4 hours.
Add the Origin Trial tag to the head of all pages. This is the recommended option for convenience and to ensure proper functionality. Please see OT docs for other option(s).
<meta http-equiv="origin-trial" content="your-token-goes-here">
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");
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.