Skip to main content

Web2App - Custom analytics integration guide

A guide on how to inject your tracking code, so you can capture detailed user interactions and send data to the preferred analytics service.

L
Written by Leanid Yuryeu
Updated today

Contents:

Implementation Instructions

  1. Access the Integration Panel

    • Navigate to the Analytics field

    • Select Web2App project

    • Scroll down the page and select "Custom analytics

    • Click "Add"

  2. Insert Your Tracking Script

    • Place your JavaScript code in either <head> or <body> section

NOTE: The function window.customEventTracker is called for every tracked event.

Basic example:

<script>
window.customEventTracker = (event, args) => {
// Your tracking implementation
console.log('TRACK EVENT:', event, JSON.stringify(args));
};
</script>

Example: tracking table cells and product selection

<script>
window.customEventTracker = (event, args) => {
if (event === 'UserUpdatedValue' && args.buttonTitle) {
window.customUserData = window.customUserData || {};
window.customUserData[args.screenId] = args.buttonTitle;
}






if (event === 'ProductSelected') {
window.customUserData = window.customUserData || {};
window.customUserData[args.screenId] = args.productId;
}



console.log('TRACK EVENT:', event, JSON.stringify(args));
};
</script>


​
​

Example of sending custom analytics events to your own backend using a POST request

<script>
window.customEventTracker = (event, args) => {
fetch('https://your-domain.com/api/track', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
event,
timestamp: new Date().toISOString(),
args
})
}).catch((error) => {
console.warn('Failed to send analytics event:', error);
});
};
</script>

Example: Tracking events in TikTok with custom mapping

<script>
window.TikTokEventMap = {
StripePurchase: 'Purchase',
StripeSubscribe: 'Subscribe',
StripeStartTrial: 'StartTrial',
StripeSetupIntentSuccess: 'AddPaymentInfo',
ProductSelected: 'AddToCart',
StripeCheckoutSessionCreated: 'InitiateCheckout',
StripeCustomerCreated: 'InitiateCheckout',
OnboardingFinished: 'Lead',
StartOnboarding: 'ViewContent',
};
function trackToTikTok(event, args) {
const mappedEvent = window.TikTokEventMap?.[event] || event;
if (typeof ttq === 'function') {
ttq.track(mappedEvent, args);
}
}
window.customEventTracker = (event, args) => {
trackToTikTok(event, args);
};
</script>
Did this answer your question?