Setting Page Context for Script Implementation

Page context is information you pass to Dynamic Yield about a page that's being viewed by a visitor to your site. The page context includes details about the page type (homepage, product page, and so on) as well as attributes (for example, if it's a product page – for which product).

🚧

Important:

You must ensure that page context is determined on every page, based on one or both of the methods described in this article. If the page context is missing, many capabilities do not work as expected. For example, page-type targeting fails, affinity profiles do not update, and recommendations are not served.

Setting page context

Step 1: Choose your method

There are 2 ways to determine the page context on your site:

  • Using code: Put a short code snippet in the tag of every page, before the Dynamic Yield script.
  • Auto-detect rules: Set rules to detect the page type and fetch its attributes. Recommended for SPAs. This is supported only for e-commerce sites using the Dynamic Yield SPA flow. Note: Contact your technical account manager to enable auto-detect.

📌

No need to choose only one option

You can implement different page types in different ways. For example, you can use code on your homepage and use auto-detect rules for product pages.

You can even use both methods for the same page types. In this case, the context is first determined by the auto-detect rules, and the code is the fallback if the rules fail for any reason.

Step 2: Set the context

Both methods start with going to Settings › General Settings in Experience OS.

Continue with the steps and information described in the following pages: