sourceConfigurationOverride Parameter Reference
Reference for the sourceConfigurationOverride
parameter used for dynamically configuring device mode destinations in the RudderStack JavaScript SDK.
Version:
4 minute read
This guide explains how to dynamically configure device mode destinations using the RudderStack JavaScript SDK.
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.
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.
In the RudderStack dashboard, go to the Settings of the destination page to find the destination ID.
To identify the exact configuration fields available for override, inspect the source configuration response from RudderStack:
sourceConfig
endpoint).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.
You can programmatically enable or disable destinations using the Boolean parameter enabled
in your override configuration.
rudderanalytics.load(<writeKey>, <dataPlaneUrl>, {
sourceConfigurationOverride: {
destinations: [
{
id: "<destination-id-1>",
enabled: false // Disables this destination
},
{
id: "<destination-id-2>",
enabled: true // Enables this destination
}
]
}
});
RudderStack supports onlytrue
andfalse
as values for theenabled
field. It will ignore any other value, and the destination configuration will remain unchanged.
You can also override destination configuration and toggle their status in a single operation.
The following example shows how to override configurations for the Google Analytics 4 and Facebook Pixel destinations.
rudderanalytics.load(<WRITE_KEY>, <DATA_PLANE_URL>, {
sourceConfigurationOverride: {
destinations: [
{
id: "<ga4-destination-id>", // Destination ID for GA 4 destination
enabled: true,
config: {
measurement_id: "<ga4-new-measurement-id>"
}
},
{
id: "<fb-pixel-destination-id>", // Destination ID for the Facebook Pixel destination
enabled: true,
config: {
pixel_id: "<new-pixel-id>"
}
}
]
}
});
To verify your setup after implementing dynamic configuration:
null
or undefined
, otherwise you might encounter an error or unexpected behavior.This section provides troubleshooting tips for common issues you may encounter when dynamically configuring device mode destinations.
If you see console warnings about invalid destination IDs:
If your configuration overrides aren’t working:
enabled
and config
fields, as other fields are not supported.If events aren’t reaching your destinations after configuration:
enabled
field to false
for destinations that should receive events.enabled
and config
fields per destination.Reference for the sourceConfigurationOverride
parameter used for dynamically configuring device mode destinations in the RudderStack JavaScript SDK.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.
Questions? Contact us by email or on Slack