Contexts - Categorizing your Pages
What is a context?
A context is a set of pages of your site that share common characteristics and a similar structure. Think of them as page "categories". The most common examples are:
- Homepage
- Product page
- Category page
- Cart
- Checkout funnel
- Login page
The function of contexts is fundamental in Netvigie Tracking. They allow you to:
- Apply specific verification rules. It makes sense to verify the presence of a price on a product page, but not on an editorial content page. Contexts make this possible.
- Obtain relevant data quality scores. Knowing that the "Tag Score is 90%" is information. Knowing that the "Tag Score is 50% on the Product Page context" is actionable information. You know exactly where to prioritize your correction efforts.
Golden rule: In Netvigie Tracking, a URL can belong to only one context. The first context whose rules are validated by the URL "wins" the URL.
Creating and Managing Contexts and Context Groups
Organization is done at two levels: context groups for filing, and contexts themselves for testing logic.
1. Create a Context Group
This is the first step for good organization.
- Go to Site > Context Groups.
- Click on Create a new context group.
- Give it a name (e.g. "Purchase journey", "Content", "Customer Account").
- You can assign a color to it for better readability.
- Save.
2. Create a Context
There are two ways to create a context: from scratch or by using the results of a crawl.
- Go to Site > Contexts.
- Click on Add a context.
- Name your context (e.g. "Product Page").
- Associate it with a context group (e.g. "Purchase journey").
- Fill in one or more example URLs.
- These are URLs representative of your context. They are crucial because they serve as a base to test your configuration live.
- Why add several? If the pages of your context have significant variations. For example, for a "Product Page" context, you could include a URL for a simple product and another for a product with options (size, color), because their structure or their dataLayer might differ.
- Define the Context Rules.
- This is the most important part. A rule determines whether a URL belongs to this context or not.
- A rule is always composed of three elements:
[Collector][Condition][Value]. - Example:
{{Page pathname}}must contain/p/. - If you define multiple rules, they are cumulative (AND logic). The URL must validate all of them to belong to the context.
- Associate a scenario (optional).
- Some pages are only accessible after a series of actions (e.g. a "My Account" page is only visible after login). In this case, you can link a scenario (e.g. a login scenario) to the context. Netvigie Tracking will execute the scenario to reach the page and test it.
- Test and Save.
- Use the Verify button to ensure that your example URLs indeed match the rules you just defined.
- Save your context.
Display Order vs Verification Order
This is a crucial distinction for the proper functioning of your tests.
- Display order:
- What? It is the order in which contexts and groups appear in the interface.
- Impact: Purely visual, for your comfort and your organization.
- How? In Site > Context Groups, you can reorganize groups and contexts within each group by simple drag and drop.
- Verification order:
- What? It is the order in which Netvigie Tracking tests contexts to assign a URL to one of them.
- Impact: Fundamental and functional. The system works on the principle of "first match wins". If a URL validates the rules of the first context in the list, it is assigned to it, and the other contexts are not even tested for this URL.
- Concrete example:
- Context A ("Product Page"): rule
pathname contains /produits/. - Context B ("Product Category"): rule
pathname contains /produits/ANDpathname does not contain .html. - A product page URL like
/produits/mon-produit.htmlcontains/produits/. If Context A is verified before Context B, the URL will be (correctly) classified as "Product Page". If the order is reversed, it will also be classified as "Product Page" because it does not validate the second rule of context B. But a category URL/produits/vetements/could be wrongly classified if rules are too simple and the order incorrect. You must therefore place the most specific contexts before the most generic ones.
- Context A ("Product Page"): rule
- How? In Site > Contexts, use the dropdown menu at the top of the table to select "Allow context reordering" and modify the order by drag and drop.