Skip to main content
All CollectionsSegmentation
How to segment groups of pages based on your Data Layer - Google Tag Manager example
How to segment groups of pages based on your Data Layer - Google Tag Manager example

Want to make your Google Analytics data consistent with OnCrawl data & reports? Here is how to create categories based on your Data Layer

Updated over 4 years ago

What is an OnCrawl Custom Field?

Custom Fields are extractor code that you setup before a crawl. They allow to extract data from each page thanks to two types of rules: XPATH and REGEX.

You may be interested in our article explaining how to create and validate a custom field.

What is a Data Layer?

A Data Layer is a JavaScript object, which contains a large amount of information, which you can then forward to a data manager (such as Google Tag Manager). The information contained in a Data Layer is highly variable: data related to mobility, personal information, e-commerce transactions. They are very different, but their presentation follows a clear rule.

The information contained in the Data Layer, i. e. the "data layer", is formed by a pair: each time you find a name, and its variable.

The Data Layer is implemented in the html code. Just like other scripts, such as Google Analytics, a Data Layer will collect interaction information, allowing you to track useful data to improve the user experience.

What is particular on GTM (Google Tag Manager)?

As it says in the Google Tag Manager documentation, here:
The Google Tag Manager container snippet is a small piece of JavaScript and non-JavaScript code that you paste into your pages. It enables Tag Manager to fire tags by inserting gtm.js into the page (or through the use of an iframe when JavaScript isn't available).

Here we are, there are variables in the pages that must be filled in to define the Data Layer (this is the case with all Data Layers based source codes).

OnCrawl allows you to extract this code during the Crawl. These Custom Fields will therefore be present in the Crawl report's data and can be used as categorization elements.

GTM example 

This example is from the Google developer help page, here.

Custom Field to extract the PageCategory value:

Custom field name: pageCategory
Rules kind:                REGEX
Extract type:             Value
Rules:                         'pageCategory' : '([^']+)'

Once you have defined your Custom Fields - as a reminder here's how to do it - and your first crawl with your custom fields is finished, click the "Configure Segmentation" on the project homepage or from any analysis page.

  • Create a new segmentation and select start from scratch.

  • Give it a name; we suggest naming it something similar to your custom field name.

  • Create a new Group, named it with the one of your Data Layer extracted text

  • Chose to filter pages with "Custom Field: [name]" "is" "[extracted text]"

  • Do this for all your groups

Tip: start typing "Custom" in the box to quickly get access to your Custom Fields

Advantages

You now have with a dynamic categorization (it will be automatically enriched after each crawl) that exactly corresponds to your Data Layer categories.

To use these new segmentations, simply choose the one that interests you thanks to the filters at the top of each OnCrawl screen.

Did this answer your question?