How to Dynamically Configure Device Mode Destinations
Beta
Dynamically override destination configurations and toggle destination status at the instrumentation level using the RudderStack JavaScript SDK.
3 minute read
This guide explains how to dynamically configure device mode destinations using the RudderStack JavaScript SDK.
Overview
Managing destination configurations across thousands of websites can be challenging when relying solely on the RudderStack dashboard. The dynamic device mode destinations configuration feature lets you override destination-specific configuration values and toggle destination status directly at the instrumentation level when initializing the RudderStack JavaScript SDK.
This approach gives you granular, flexible control over your SDK behavior without needing to update configuration from the RudderStack dashboard for each website or application.
You can override specific configuration values for your destinations using the sourceConfigurationOverride option in the SDK’s load API.
Basic configuration override
rudderanalytics.load(<WRITE_KEY>,<DATA_PLANE_URL>,{sourceConfigurationOverride:{destinations:[{id:"<destination-id>",// Destination ID for the Facebook Pixel destination
config:{pixel_id:"new_pixel_id_value",project_key:"updated_project_key"}},{id:"<destination-id-1>",// Destination ID for the Google Analytics 4 destination
config:{measurement_id:"G-XXXXXXXXXX"}}]}});
See the Configuration merging strategy section for more information on how the SDK merges the configuration overrides with the source configuration from RudderStack.
Obtain the destination ID
In the RudderStack dashboard, go to the Settings of the destination page to find the destination ID.
Determine the configuration fields to override
To identify the exact configuration fields available for override, inspect the source configuration response from RudderStack:
Open your browser’s developer tools.
Navigate to the Network tab.
Load your web page with the RudderStack SDK.
Look for the source configuration request (typically to sourceConfig endpoint).
Examine the response (destinations[index].config) to see the available configuration fields for each destination.
Configuration fields may change over time as destinations are updated. Always verify the current field names in the source configuration response before implementing the overrides.
Verification
To verify your setup after implementing dynamic configuration:
Check the browser console for any warnings about invalid destination IDs.
Confirm that events are being sent to the correct destinations with updated configuration values.
Use your destination’s analytics interface to verify that data is flowing as expected.
Best practices
Use overrides only when necessary to maintain clear and traceable configuration behavior.
Use exact property names as they appear in the source configuration response.
Validate destination IDs before using them in configuration overrides.
Do not override the required fields to null or undefined, otherwise you might encounter an error or unexpected behavior.
Test configuration changes in a development environment first.
Troubleshooting
This section provides troubleshooting tips for common issues you may encounter when dynamically configuring device mode destinations.
Invalid destination ID warnings
If you see console warnings about invalid destination IDs:
Verify that the destination ID in your override matches exactly with the destination ID present in the dashboard.
Ensure the destination is configured as a device mode destination in the RudderStack dashboard.
Verify that the destination corresponding to the destination ID is enabled.
Configuration not taking effect
If your configuration overrides aren’t working:
Confirm you’re specifying the correct field names by inspecting the source configuration response.
Verify that the data types of your override values match the expected format.
Check that you’re only overriding the config field, as other fields are not supported.
Events not reaching destinations
If events aren’t reaching your destinations after configuration:
Verify that required configuration fields (like measurement IDs or pixel IDs) are set correctly.
Check your destination’s debug or real-time view to confirm event delivery.
Limitations
You can override the configuration for only the device mode destinations.
You can override only the config field per destination.
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.