Mastering Dynamic Value Passing in CM360 with the Pattern Matching Macro

Subscribe to our monthly newsletter to get the latest updates in your inbox

The need to pass dynamic values or data in placement tags, landing page URLs or Floodlight tags is a common challenge for Campaign Manager 360 (CM360) managers and traffickers. Fortunately, you can accomplish this with the versatile pattern-matching macro, also known as the %p macro.

The %p macro is used to grab a dynamic value from a source (often a Floodlight or publisher site) and expands the value into a designated parameter. This allows agencies and advertisers to share dynamic data with third- or fourth-party partners or the advertiser’s site analytics. Some typical applications of the %p macro include:
  • Capture unique event or site data for report tracking when the ad serves
  • Pass values dynamically into landing page URLs from the publisher
  • Passing values or variables from Floodlight tags to publisher tags
To illustrate how this could work in a live setting, we’ll use a scenario where a brand that manufactures high-end bicycles is running ad placements with a publisher that curates and reviews luxury goods. These products fall into the various categories on the publisher’s site, such as Cars, Jewelry, Watches and Hotels.

In this instance, the advertiser is promoting their most premium bicycles in a run-of-site (ROS) test with the publisher. With this test, the brand wants to determine the page categories where their ads perform best so they can do a targeted buy with the publisher in a subsequent rollout.

In this case, the publisher can dynamically pass the page category where the Ad is serving to a unique parameter (key-value) within the Placement tag. When a user clicks on an Ad Creative, the page category value will be expanded with the %p macro and appended to the landing page URL before being passed into the advertiser’s site analytics.

How to Set Up And Use the Pattern Matching Macro

The following details the steps to set up the key-value pair and the pattern match macro in the landing page URL suffix.

Step 1: Set up the key-value pair in the Placement properties:

In this example, we’ll use the key page_category. The key should be the name of the variable on the publisher’s site, where the dynamic value will be populated by a macro or code snippet by the publisher
  1. Navigate to the Placement properties and select Tag defaults.
  2. Set up the key-value pair in the Additional key values section. The format of the key-value pair is key=value.

    Enter page_category=[page_category] in the Additional key-values box. (see screenshot below).

    NOTE: The brackets ([ ]) around the value are optional. Some developers find them useful as placeholders for their code snippets or macros.


Screenshot of CM360 showing example of where to enter the key-value pair.


It will look like this after you enter the key-value pair.

Screenshot of CM360 showing example of what it will look like after you enter the key-value pair.


Step 2: Set up the pattern-matching macro in the Ad properties

In this step, add the %p macro in the Landing page URL suffix query parameters to capture page_category value from the publisher’s site.
  1. Navigate to the Ad properties and select Landing page URL suffix.
  2. Press the lock icon in the URL suffix configuration to unlock the edit feature.
  3. You can either click Add query parameter to build the suffix parameter OR type/paste the desired parameter in the URL suffix box. In this case, we’ll use the Google Analytics parameter utm_term=.
  4. Set up the pattern match macro to pass the value for the key/variable page_category. The syntax for the pattern matching macro is “%pstart key string!end character”.

    For our purposes, the start key string is the key-value page_category. The end character is usually the semicolon delimiter “;”. I

    The final statement appears as %ppage_category!;.

    NOTE: The exclamation point (!) is part of the code syntax and is required to dynamically return the value passed to the key.
  5. Here we can see the URL suffix set up to use the pattern match macro to capture the publisher’s variable value page_category for the UTM parameter term (utm_term). The macro will capture the string of alphanumeric characters between page_category= (the start key string) and ; (the end character).


Location of Landing page URL suffix feature in CM360


Step 3: Send the Placement tags to the publisher

It’s a good idea to check the tag sheet before sending it to the publisher to ensure the key-value pair is in the tag. In the iframe/JavaScript tag below, the key-value pair is present so the publisher can add their code to pass the page_category= value and implement the tag.

CM360 Placement tags example, showing location of added key-value pair


Wrapping Up

With trafficking, setup and implementation complete, we can see the final result of %p macro. In this example, the publisher has implemented the placement tags and the campaign is live. A user clicks on the advertiser’s ad on the site’s Hotels page. Below is how the URL appears with the dynamically generated page_category value passed to the advertiser’s site analytics in the utm_term parameter.

CM360 example, showing location of added key-value pair in URL from successfully implemented placement tags.

If you have any questions about the %p macro, please don’t hesitate to contact us.