Introduction
In today’s digital landscape, a significant portion of online users employ ad blockers like uBlock Origin, AdGuard, and Total Adblock. These ad blockers are adopted to combat intrusive advertising, enhance browsing speed, and protect online privacy. However, the prevalent adoption of ad blockers presents a significant obstacle for B2C brands that depend on precise user data. Ad blockers frequently employ domain blacklisting to detect and block communication with domains known for tracking. Consequently, this leads to the collection of incomplete or unreliable data. To overcome these limitations, MoEngage suggests using Custom Proxy Domains. This technical documentation details an integration method that routes SDK traffic through your own subdomain, bypassing blacklist filters while maximizing data fidelity.Implementation Guide
Prerequisite: DNS DelegationBefore updating your SDK code, you must delegate a subdomain to MoEngage. Please refer to our DNS Delegation Help Documentation for the step-by-step process on picking a domain and configuring NS records.
Implementation Process
The MoEngage Web SDK uses an internal interceptor and hostname replacement to dynamically rewrite outgoing requests. Instead of reaching out to standard MoEngage endpoints, the SDK prefixes your custom subdomain to all network calls, including API data, scripts, and campaign assets (images). The process involves:- Updating the SDK initialization script on your website.
- Updating the Service Worker (
serviceworker.js) file. - Optional: Implementing the Web Personalization snippet.
Updating the SDK Initialization
When implementing the initialization code, replace the standard script with the snippet below. You must define yourmoeDataCenter, moeAppID, and customProxyDomain. This script dynamically constructs the scriptHost to ensure the SDK itself is loaded from your proxied CDN.
Updating the Service Worker (SW)
If you are using Push Notifications or other background features, you must also update theserviceworker.js (or your custom service worker file) to include the proxy domain.
Web Personalization Integration
If your account uses Web Personalization, you must add the following tags to the top of the<head> section of your HTML file. This ensures that personalization scripts and campaign assets are pre-fetched and loaded via your custom proxy domain.
Verifying the Interceptor
Once integrated, the SDK’s internal interceptor will automatically map requests as follows:| Original Endpoint | Proxied Endpoint |
|---|---|
sdk-0x.moengage.com | sdk-0x.yoursubdomain.yourdomain.com |
cdn.moengage.com | cdn.yoursubdomain.yourdomain.com |
image.moengage.com | image.yoursubdomain.yourdomain.com |
app-cdn.moengage.com | app-cdn.yoursubdomain.yourdomain.com |