Articles on: Website

Retrieving Datalayer values from GTM

The DataLayer is a hidden layer on top of your website where additional information is stored. Through Google Tag Manager, you can use this layer to dynamically retrieve and utilize information in tags, triggers, and variables. When a customer places an order in your webshop, this information is recorded in the DataLayer on the thank you page. You can use this data to create variables in Google Tag Manager, such as the ‘value’ variable. This variable can then be used to send the order value to Facebook to calculate the Return On Ad Spend (ROAS) of your Facebook campaign.

How to Use DataLayer Values in Google Tag Manager



Go to variables and create a "user-defined variable"

Go to variables

Create a user defined variable

Create a datalayer variable:

Select Datalayer Variable

Make sure to copy the “key value” of the value so you can paste it into the “Data Layer Variable.” To retrieve the Key value, it is best to use the DataLayer checker. You can install this extension via this link: https://chromewebstore.google.com/detail/datalayer-checker/ffljdddodmkedhkcjhpmdajhjdbkogke You can see how to copy the key value in the screenshot below:

Copy the key value

In this case, “client_id” is chosen. If you were to copy this key value, you would get: marketing.client_id.

Example of marketing.client_id

Next, when creating a Tag, you can ensure that the data from the DataLayer is attached to an event using parameters. To do this, click on the configuration block:

Configuration

The parameter name value is called user_data.email_address and comes from the standard list that Google recommends for naming parameters: https://developers.google.com/tag-platform/tag-manager/server-side/common-event-data. These standard names are compatible with all other settings.

Next you select the right variable

Add Parameter to datalayer

Do I need a datalayer?



It depends on what you want to know about your visitors. For example, if you want to know if someone has previously downloaded an eBook or Whitepaper during the process, you might choose to use a DataLayer. You could, for instance, include the email address in the DataLayer. For eCommerce websites, you definitely need a DataLayer to dynamically retrieve all the correct data per visitor for all your marketing and analytics platforms.

How can I install a datalayer?


You can ask your web developer about this. Most systems have a DataLayer built in by default. You can easily check this by setting Google Tag Manager to Preview mode. For AdPage’s Server-Side Tagging implementations for Shopify, WooCommerce, WordPress, Magento, and Lightspeed, this is almost always included.

Through the following link, you can find which parameters (key values) are available:
DataLayer events & parameters for Shopify, Lightspeed, Magento, WooCommerce

Updated on: 15/08/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!