Context and context keys

Overview

A context is defined on conditions based on the audience and/or page type of a visit for an ad call.

With our context system, you can configure the right advertising stack to be run to the right user on the right page. Providing you with full control and flexibility on your monetization.

Few examples of contexts:

  • Homepage for logged visitors
  • Consent-less visitors
  • Mobile pages of article in sport section

You can imagine various conditions to define a context.

Pubstack relies on context keys & logical conditions to identify a particular context.

Context keys

Before creating a context, you’ll need to define the necessary context keys to set its conditions

What are context keys?

Context keys are the conditions that allow you to define the context of a page. Based on context keys, you can configure the right advertising stack to be run to the right user on the right page. Providing you with full control and flexibility on your monetization.

Context keys are also used to define the ad unit path to build requests to ad servers such as Google Ad Manager.

How to define a context key?

A context key is defined by its name and its values. For each key, a default value can be set in case of missing information or an undefined value. Once a context key is created, name and values cannot be edited but new values can be added.

If no default value is set, then a "blank” value will be considered as default.

Implementation on the page

Each context key should be implemented by a <meta> tag in the page code, following this structure:

<meta name=”**pbstck_context**:context_key_name” content=”your_value”/>

Example to identify an article, on mobile, on a specific site :

<head> 
<meta name=”pbstck_context:site_name” content=”mysite”/>
<meta name=”pbstck_context:device_type” content=”mobile”/>
<meta name=”pbstck_context:page_type” content=”article”/>

</head>

So for each meta tag in the pages, you needs to create a corresponding context key (name + value) on the Pubstack platform to map to.

Access

Click on Context keys nav menu from https://app.pubstack.io/adstack/context/context-keys

Create/Edit New Context key

If there is no Context keys created yet, this screen is displayed.

NoCntxt

Click on the button New context key to access the following screen to create a new context key.

NewContxt

Fill in the Name and Values fields and validate context key creation.

NewContxtKey2

Name

Note that quotes and spaces are not allowed.

The name of the context key cannot be edited after it is saved, as it would cause a discordance between your website and Pubstack.

If you wish to change the name of a context key simply modify its name in your website’s code, and create a new matching context key on our platform.

Value

You can add one or more value for a key by pressing enter.

Default Value

You can click on a created value to make it value by default. That value will be highlighted in a different color and have a star symbol. This value will be used in case of missing or unknown value. This feature is optional and should only serve as a failsafe. If not default value is set and no value is received, then a "empty” / ”blank” value will be used.

Creating a context

Once you have defined the necessary context keys you are ready to create a context.

To do so, go to the context tab under Ad stacks, or click https://app.pubstack.io/adstack/context/contexts.

Once there, click the "new context” button to be brought to this page:

NewContext

Here you can fill in the context’s name as well as its conditions.

Once the context is validated you will not be able to modify it.

To create the conditions for your context, choose a context key and the value for which you want to enable the stacks you will connect to this context.

After the first condition is set, you can choose to add more conditions through the corresponding button or validate our new context.

 Screen Shot 2023-07-19 at 10.40.24 AM

Once validated, you will be brought back to the context page where all your contexts are shown:
CntxtList

Here we can see that the context key "context2” is not used on any stack. To get it out of the way until it is needed it is possible to archive it.

To do so, simply click the blue box in the rightmost column. Once this is done, the context will be greyed out and moved to the bottom of the list until it is unarchived.

To unarchive a context, click on the same symbol used to archive it.

CntxtListArchive

Once you have contexts, you can use it to define when a certain stack on a website should be used.

To see how stack implementation is done, please refer to Stacks.

Contexts can be used in the stacks of multiple websites, but can only be used for one stack per website.

Why do I need to define the Network ID?

The network code is a unique, numeric identifier for an Ad Manager network. This network code is used to build the Ad request to Google Ad Manager. You can get it directly on your Ad manager account.

Why do I need to define the network ID for Multiple Customer Management (MCM)?

Publishers can delegate management of their Ad Manager network to a third-party publisher upon request and establishes a relationship parent-child.
To be compliant with this delagation for Google, the Ad unit path declared in Google Publisher Tag must contain explicitly this link.
You may not need to fill in this information, but if you have a delegated relationship with a third party, you must define it otherwise the inventory cannot be monetized. You can get it on your Ad Manager account.

Why do I need to define the ad unit path?

You must provide to Pubstack with the architecture you are using to help it properly handle requests to your Ad Manager network.

How can I define the ad unit path?

Based on context keys, and ad units you have already set in Pubstack app, you have two ways to define your ad unit path architecture:
  • First common one relies on context keys and Ad server ad unit name
    • Example: ContextKey_1/ContextKey_2/AdServerAdUnitName( site_name/inventory_type/MyAdUnit)
  • The second way depends on context keys. If you don’t have an explicit ad unit to target in your ad manager, Pubstack will send targeting keys to the ad server based on the ad unit name and key values defined in the ad unit settings. In that case, ad unit path will be ContextKey_1/ContextKey_2/ContextKey_3 (ex: site_name/inventory_type/section) and Pubstack will complete it by sending pbstck_adunit_name=AdServerAdUnitName & associated key values (ex: position=top)

What do I need to declare if I use different levels for the ad unit path on the same site?

If you have manage a site for which you have some specific sections where you have a different level of ad unit path, you have to define the longest one you currently use on your Ad Manager.

Pubstack will be able to deal with N levels and N+1 levels. Even is the last level is missing on the page, Pubstack will call the ad unit in GAM with the right path.