How to Create Custom Web Device Mode Integrations
Beta
Create custom web device mode integrations in RudderStack.
4 minute read
This guide lists the steps to set up a custom web device mode destination in RudderStack and the necessary SDK configuration required to send events correctly.
Prerequisites
Before you start creating custom device mode integrations, make sure you have:
A JavaScript source set up in your RudderStack workspace and integrated with your website
Access to your third-party tool’s API, documentation, and SDK
Custom Device Mode destination enabled — contact your Customer Success Manager or RudderStack Support to enable this integration for your RudderStack workspace.
Create a custom device mode destination in your RudderStack dashboard by following these steps:
Navigate to the JavaScript source set up in your RudderStack dashboard.
In the Overview tab, click Add Destination > Create new destination.
Select Custom Device Mode from the list of destinations and click Continue.
Configure the following settings:
Setting
Description
Name
Assign a name to uniquely identify the destination in RudderStack.
Connection mode
Device mode is selected by default, as this is a web device mode-only integration.
Configure the other optional settings as per your requirements:
Setting
Description
Consent management settings
Configure the consent management settings for the specified source by choosing the Consent management provider from the dropdown and entering the relevant consent category IDs.
This section covers the functions you need to implement to correctly create your custom web device mode integration.
Your implementation determines the supported event types and how the integration handles them.
Initialize the third-party SDK
Use the init function to load and configure your third-party SDK:
init:(destinationConfig,analytics,logger)=>{logger.debug('Loading third-party SDK');// Dynamically load the SDK script
constscript=document.createElement('script');script.src='https://cdn.your-sdk.com/sdk.js';script.onload=()=>{// Initialize the SDK once loaded
window.YourSDK.init({apiKey:destinationConfig.apiKey,// Add other configuration options
});};document.head.appendChild(script);}
Check integration readiness
Note that isReady is the only required function — it tells RudderStack when your integration is ready to receive events:
isReady:(analytics,logger)=>{// Check if your third-party SDK is loaded and initialized
returnwindow.YourSDK&&window.YourSDK.initialized===true;}
If isReady doesn’t return true within 11 seconds, RudderStack will time out and skip your integration.
Handle events
Make sure to implement only the event types your integration supports:
track:(analytics,logger,rsEvent)=>{try{// Extract event data
consteventName=rsEvent.message.event;constproperties=rsEvent.message.properties;// Send to your third-party tool
window.YourSDK.track(eventName,properties);logger.debug('Track event sent successfully');}catch(error){logger.error('Failed to send track event:',error);}}
4. Test the integration
After implementing your custom integration, verify it works correctly by following these steps:
Open your browser’s developer console.
Look for any debug messages (after configuring the required log levels in the JavaScript SDK) from your integration.
Check that events are being sent to your tool.
Test different event types (track, page, identify) to ensure they’re handled properly.
Troubleshooting
Issue
Solution
Integration not initializing
Make sure to call addCustomIntegration() before rudderanalytics.load().
Events not being sent
Check that isReady returns true.
Third-party SDK not loading
Verify the script URL and check for console errors.
Configuration not available
Ensure your destination is properly configured in the RudderStack dashboard.
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.