Dynamic variables
Dynamic variables let you copy values from one variable to another without increasing image request length. They are helpful when capturing the same data in multiple variables.
In previous versions of Analytics, image request length was important to prevent truncated data. Improvements to AppMeasurement allow much longer image request query strings, so dynamic variables are typically not needed.
Dynamic variables support query string parameters or HTTP headers in an image request. See data collection query parameters for a full list of available parameters to reference. See on Wikipedia for a full list of available HTTP request fields to reference.
When ÃÛ¶¹ÊÓƵ recognizes a dynamic variable prefix, it automatically copies the query string or HTTP header value in your report suite. This action happens before any other processing, including processing rules and VISTA rules.
eVar1
to prop1
, prop1
can have a truncated value since it has a 100-byte limit (whereas eVar1
has a 255-byte limit).Dynamic variables using the Web SDK
Use Datastream mapping to send data to multiple Analytics variables from a single XDM field.
- Log in to using your ÃÛ¶¹ÊÓƵID credentials.
- Click Datastreams in the left rail.
- Click the desired datastream.
- Click Edit Mapping on the right.
- Map the desired Source Field to the desired Target Field. A single source field can map to any number of target fields.
Dynamic variables using the ÃÛ¶¹ÊÓƵ Analytics extension
You can use dynamic variables in any dimension field that accepts a string. Dimension items are typically set while configuring the Analytics extension (global variables) or under rules.
- Log in to using your ÃÛ¶¹ÊÓƵID credentials.
- Click the desired tag property.
- Go to the Rules tab, then click the desired rule (or create a rule).
- Under Actions, click an existing ÃÛ¶¹ÊÓƵ Analytics - Set Variables action or click the ‘+’ icon.
- Set the Extension drop-down list to ÃÛ¶¹ÊÓƵ Analytics, and the Action Type to Set Variables.
- Locate the desired dimension item.
Place the dynamic variable prefix in the text field, followed by the query string parameter or HTTP header that you want to reference. By default, the dynamic variable prefix is D=
.
Dynamic variables in AppMeasurement and the Analytics extension custom code editor
Dynamic variables are text strings assigned to other variables. The default dynamic variable prefix is D=
. Dynamic variables are case-sensitive.
// Copy eVar1 into eVar2. The query string parameter of eVar1 is v1.
s.eVar1 = "Example value";
s.eVar2 = "D=v1";
// Take the user agent string found in the image request HTTP header and place it in eVar1.
s.eVar1 = "D=User-Agent";
// Copy the page URL and place it in eVar1. The query string parameter of page URL is g.
s.eVar1 = "D=g";