0% found this document useful (0 votes)
99 views5 pages

How To Collect Dynamic Values Using Data Layer Variables - Analytics Help

The document describes how to collect dynamic values from a website using Data Layer variables in Google Analytics. It involves: 1) Creating a Data Layer variable to store the trip value from the website. 2) Adding JavaScript to extract the trip price from the URL and push it to the Data Layer. 3) Setting up a Custom Metric in Analytics to collect the trip amount and mapping it to the Data Layer variable in Tag Manager. 4) Building a Custom Report in Analytics to view transaction data including the trip revenue metric.

Uploaded by

radhika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views5 pages

How To Collect Dynamic Values Using Data Layer Variables - Analytics Help

The document describes how to collect dynamic values from a website using Data Layer variables in Google Analytics. It involves: 1) Creating a Data Layer variable to store the trip value from the website. 2) Adding JavaScript to extract the trip price from the URL and push it to the Data Layer. 3) Setting up a Custom Metric in Analytics to collect the trip amount and mapping it to the Data Layer variable in Tag Manager. 4) Building a Custom Report in Analytics to view transaction data including the trip revenue metric.

Uploaded by

radhika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

10/14/2020 How to collect dynamic values using Data Layer variables - Analytics Help

How to collect dynamic values using Data Layer variables


Tag Manager lets you pass dynamic values such as revenue from your website into Custom Metrics that you can use in
Analytics to analyze things like purchase behavior.

Create a user-de ned Data Layer variable


To set this up, let’s create a user-de ned Data Layer variable for “Trip Value.” Click “Variable.” Then we’ll scroll down. Now
select “New.” Next, choose “Data Layer Variable.” We’ll title the variable “tripValue” and enter the variable name “tripValue.”
We’ll leave the Data Layer version as the default. Then we’ll select “Create Variable.”

Add the Data Layer


Next, we’ll add the Data Layer code to the Trip Purchase “Thank You” page that passes the total trip value from the URL to
the Data Layer.

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.

Set up a Custom Metric in Analytics


Since The Great Outdoors uses Universal Analytics, we can set up a Custom Metric to collect the trip amount. Custom
Metrics are set up similarly to Custom Dimensions.

Click “Admin.” Then under “Property,” select “Custom De nitions.” Then “Custom Metrics.”

Now click “New.”

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.

Update the Analytics tag in Tag Manager


Similar to our “Trip Category” and “Trip Location” dimensions, we’ll have to update our Analytics tag within 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.”

Then click “Add Custom Metric.”

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

Click “Continue.” Then click “Save Tag.”

Build a Custom Repo in Analytics


Now that we’ve set up our Custom Metric and mapped it back to Tag Manager, we can build a Custom Report in Analytics
to view the transaction data.

In Analytics, at the top, click “Customization.”

Then click “New Custom Report.”

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.

To save this custom report, click “Save.”

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.

Give feedback about this article

Was this helpful?

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

Need more help?


Try these next steps:

Ask the Help Community


Get answers from community experts

Contact us
Tell us more and we’ll help you get there

https://support.google.com/analytics/answer/6223390?hl=en 5/5

You might also like