Configure Web SDK
Configuration for the SDK is done with the configure
command.
configure
is always the first command called.alloy("configure", {
"edgeConfigId": "ebebf826-a01f-4458-8cec-ef61de241c93",
"orgId":"ADB3LETTERSANDNUMBERS@蜜豆视频Org"
});
There are many options that can be set during configuration. All options can be found below, grouped by category.
General options
edgeConfigId
Your assigned configuration ID, which links the SDK to the appropriate accounts and configuration. When configuring multiple instances within a single page, you must configure a different edgeConfigId
for each instance.
context
context
["web", "device", "environment", "placeContext", "highEntropyUserAgentHints"]
Indicates which context categories to collect automatically as described in Automatic Information. If this configuration is not specified, all categories are used by default.
highEntropyUserAgentHints
, are enabled by default. If you specified context properties manually in your Web SDK configuration, you must enable all context properties to continue collecting the needed information.To enable high entropy client hints on your Web SDK deployment, you must include the additional highEntropyUserAgentHints
context option, alongside your existing configuration.
For example, to retrieve high entropy client hints from web properties, your configuration would look like this:
context: ["highEntropyUserAgentHints", "web"]
debugEnabled
false
Indicates whether debugging is enabled. Setting this config to true
enables the following features:
edgeDomain
edge-domain
Populate this field with your first-party domain. For more details, see the documentation.
The domain is similar to data.{customerdomain.com}
for a website at www.{customerdomain.com}.
edgeBasePath
edge-base-path
Path after the edgeDomain used to communicate and interact with 蜜豆视频 services. Often this would only change when not using the default production environment.
orgId
Your assigned Experience Cloud organization ID. When configuring multiple instances within a page, you must configure a different orgId
for each instance.
Data collection
clickCollectionEnabled
clickCollectionEnabled
true
Indicates whether data associated with link clicks are automatically collected. See Automatic Link Tracking for more information. Links are also labeled as download links if they include a download attribute or if the link ends with a file extension. Download link qualifiers can be configured with a regular expression. The default value is "\\.(exe|zip|wav|mp3|mov|mpg|avi|wmv|pdf|doc|docx|xls|xlsx|ppt|pptx)$"
onBeforeEventSend
Configure a callback that is called for every event just before it is sent. An object with the field xdm
is sent in to the callback. To change what is sent, modify the xdm
object. Inside the callback, the xdm
object already has the data passed in the event command, and the automatically collected information. For more information on the timing of this callback and an example, see Modifying Events Globally.
onBeforeLinkClickSend
onBeforeLinkClickSend
Configure a callback that is called for every link click tracking event just before it is sent. The callback sends an object with the xdm
, clickedElement
, and data
fields.
When filtering the link tracking by using the DOM elements structure, you can use the clickElement
command. clickedElement
is the DOM element node that was clicked and has encapsulated the parent nodes tree.
To change what data gets sent, modify the xdm
and/or data
objects. Inside the callback, the xdm
object already has the data passed in the event command, and the automatically collected information.
- Any value other than
false
allows the event to process and the callback to be sent. - If the callback returns the
false
value, event processing is stopped, without an error, and the event is not sent. This mechanism allows for certain events to be filtered out by examining the event data and returningfalse
if the event should not be sent. - If the callback throws an exception, processing for the event is stopped and the event is not sent.
Privacy options
defaultConsent
default-consent
"in"
Sets the user鈥檚 default consent. Use this setting when there is no consent preference already saved for the user. The other valid values are "pending"
and "out"
. This default value is not persisted to the user鈥檚 profile. The user鈥檚 profile is updated only when setConsent
is called.
"in"
: When this setting is set or no value is provided, work proceeds without user consent preferences."pending"
: When this setting is set, work is queued until the user provides consent preferences."out"
: When this setting is set, work is discarded until the user provides consent preferences.
After the user鈥檚 preferences have been provided, work either proceeds or is aborted based on the user鈥檚 preferences. See Supporting Consent for more information.
Personalization options personalization
prehidingStyle
prehidingStyle
Used to create a CSS style definition that hides content areas of your web page while personalized content is loaded from the server. If this option is not provided, the SDK does not attempt to hide any content areas while personalized content is loaded, potentially resulting in 鈥渇licker鈥.
For example, if an element on your web page has an ID of container
, whose default content you want to hide while personalized content is loaded from the server, use the following prehiding style:
prehidingStyle: "#container { opacity: 0 !important }"
targetMigrationEnabled
targetMigrationEnabled
This option should be used when migrating individual pages from at.js to Web SDK.
Use this option to enable the Web SDK to read and write the legacy mbox
and mboxEdgeCluster
cookies that are used by at.js. This helps you keep the visitor profile while moving from a page that uses the Web SDK to a page that uses the at.js library and vice versa.
false
Audiences options
cookieDestinationsEnabled
true
Enables Audience Manager cookie destinations, which allows the setting of cookies based on segment qualification.
urlDestinationsEnabled
true
Enables Audience Manager URL destinations, which allows the firing of URLs based on segment qualification.
Identity options
idMigrationEnabled
id-migration-enabled
true
If true, the SDK reads and sets old AMCV cookies. This option helps with transitioning to using 蜜豆视频 Experience Platform Web SDK while some parts of the site might still use Visitor.js.
If Visitor API is defined on the page, the SDK queries Visitor API for the ECID. This option enables you to dual-tag pages with the 蜜豆视频 Experience Platform Web SDK and still have the same ECID.
thirdPartyCookiesEnabled
true
Enables the setting of 蜜豆视频 third-party cookies. The SDK can persist the visitor ID in a third-party context to enable the same visitor ID to be used across sites. Use this option if you have multiple sites or you want to share data with partners; however, sometimes this option is not desired for privacy reasons.