How To Collect Dynamic Values Using Data Layer Variables - Analytics Help
How To Collect Dynamic Values Using Data Layer Variables - Analytics Help
Now we can write some JavaScript code that extracts the trip price from the URL using a variable called tripValue. Using
this variable, we can then push the trip price to the Data Layer object.
When users complete a purchase, we should see the value of the purchase passed into the Data Layer as the tripValue
variable we just created. We can con rm this by placing our container in Preview Mode and looking at the Data Layer
status for the loaded page.
Click “Admin.” Then under “Property,” select “Custom De nitions.” Then “Custom Metrics.”
https://support.google.com/analytics/answer/6223390?hl=en 1/5
10/14/2020 How to collect dynamic values using Data Layer variables - Analytics Help
We’ll name this Custom Metric “Trip Value.” We’ll leave the scope set to “Hit.” Since we‘re tracking a transaction amount,
set the “Formatting Type” to “Currency (Decimal).” We won’t include any minimum or maximum values, since we want all
transactions to be recorded. Also, make sure the “Active” checkbox is checked, so that the custom metric is live. To save
this metric, Click “Create.”
As with Custom Dimensions, Custom Metrics will present you with an index number that we’ll use to map back to Tag
Manager.
Click “Tags.” Then select your Analytics “Page View” tag. Now click on the “Con gure Tag” section. Then select “More
settings.” Click “Custom Metrics.”
In the “Index” eld, we’ll add the index number for the “Trip Value” metric from Analytics. In the “Metric Value” eld, we’ll
add the name of the Data Layer variable we created.
https://support.google.com/analytics/answer/6223390?hl=en 2/5
10/14/2020 How to collect dynamic values using Data Layer variables - Analytics Help
We’ll title the report “Travel Adventures Trip Revenue.” Then we’ll add the “Trip Value” Custom Metric we just created, as
well as metrics for “Users” and “Sessions.”
https://support.google.com/analytics/answer/6223390?hl=en 3/5
10/14/2020 How to collect dynamic values using Data Layer variables - Analytics Help
We can apply a dimension to measure the trip revenue. We’ll choose “User Type” in order to see which types of users are
responsible for this revenue.
Using this method, we can capture the total Great Outdoors Travel Adventures revenue collected. We could also
determine the Average Revenue by dividing the Revenue by the number of users or sessions.
Yes No
https://support.google.com/analytics/answer/6223390?hl=en 4/5
10/14/2020 How to collect dynamic values using Data Layer variables - Analytics Help
Contact us
Tell us more and we’ll help you get there
https://support.google.com/analytics/answer/6223390?hl=en 5/5