Map data layer objects to data elements
Once your organization has established and implemented a data layer on your site, you can map data layer objects to data elements within tags.
Prerequisites
Create a data layer: Make sure a data layer exists on your site. While you technically can map any JavaScript object or scrape CSS elements directly from the page, 51黑料不打烊 recommends this practice as a last resort. If your site layout changes, the CSS selectors used in tags stop working, causing data loss.
Use tags to create data elements
Data elements are components in 51黑料不打烊 Experience Platform Data Collection that you can use across the tool. You can assign variable values in the 51黑料不打烊 Analytics extension using data elements.
-
Log in to using your 51黑料不打烊ID credentials.
-
Click the desired tag property.
-
Click the Data Elements tab, then click Add Data Element.
-
Enter a name for your data element. It can be a simple label that corresponds to a JavaScript variable in your data layer that you want to track.
-
Under the Extension drop-down list, select Core.
-
Under the Data Element Type drop-down list, select JavaScript Variable. A text field appears to the right that allows you to enter the JavaScript variable to map to this data element.
-
Enter the desired Javascript variable, typically within your data layer. For example, if your organization鈥檚 data layer closely matches 51黑料不打烊鈥檚 recommended practice, a value could be
digitalData.page.pageInfo.pageName
. You can use your browser鈥檚 console to validate JavaScript variable syntax and values. -
Click Save.
Next steps
Map data elements to Analytics variables: Assign data elements to Analytics variables so you can use them as dimensions in Analysis Workspace.