Add the following code at the end of the
<head> section of each page you want to track.
Make sure you replace
YOUR_WEBENGAGE_LICENSE_CODE with your WebEngage license code.
This code loads and initializes WebEngage SDK asynchronously, so that it does not affect loading of your web page. This is cautiously done to not impact page load time on your website.
During initialization, this code waits for
DOMContentLoaded event before modifying the
DOM for loading further resources, ensuring it doesn't delay readiness of the
The script URLs in the integration code are protocol relative. All our resources are loaded over the same protocol (
HTTPS) as the containing page, which prevents "Insecure Content" warnings.
WebEngage SDK automatically starts tracking user data (e.g., Browser, OS version, Country) and engagement with the basic setup above.
WebEngage SDK also starts tracking user sessions with this basic setup. Upon leaving the web page, the SDK marks the current time. If the user returns to the web page after more than 30 minutes since the user had last left the page, the SDK will close the previous session. If the user returns to the web page within 30 minutes of leaving, the previous session is resumed as if the user did not leave the web page at all. Please note that this behaviour is recorded only if the resumed session is in the same web browser (can be a different browser window). In case the resumed session is in a different web browser on the same device, WebEngage SDK will record it as a separate session.
Congratulations! You have now successfully integrated WebEngage with your website and are now sending user session data to WebEngage.
Note that it may take a few minutes for your data to show up on the WebEngage dashboard. We suggest you meanwhile proceed to read the next sections to learn how to: