Passing Information to DFP by using Patterns

Introduction

ADVERTISING

Sometimes, you need to be able to pass variables into your Creative. Unfortunately, DFP Small Business doesn’t support this very well. That’s not to say that they don’t support it, they do. But the limitations on how they support can make it unusable in some circumstances.

The Pattern Method

Utilizing the tagging system in DFP, you can tag pages with certain attributes. You can also pass these attributes values into your Creatives (Third Party) by using the Pattern Macro (%%PATTERN:attribute name%%). Can I pass custom variables into a tag?

There are two methods of doing the Pattern method. You can use use the attributes as a actual value or a superficial value. You can also mix and match these methods.

Actual Usage

Actual usage refers to the fact that the Attribute that is put on the page has an actual purpose on the page. For example, you might tag a webpage with “Type = Sports”. This has an actual value that you may want to use in targeting your Line Items.

Example:

Add the following Javascript in your DFP Header Tag. Find:

<script type='text/javascript'>
GA_googleFetchAds();
</script>

and add above:

<script language="JavaScript">
GA_googleAddAttr("Passing", "Pattern");
</script>

The above code puts an attribute “Passing” with the value “Pattern”.

The Line Item settings is:

dfp-pattern-setting

To define a custom key go to the Inventory Tab and click on Custom targeting.
custom_new_key
Click on New key and for this example name the key ‘Passing” then select the radio button ‘Users will enter targeting values when creating line items or checking inventory.’ and click Save. Now you can select the Key ‘Passing‘ as Custom Criteria in your Line Item Settings.

And the Creative:

<div style="width:300px; height:250px; padding: 20px; border: blue solid 2px;">
DFP Passing attribute should have the value of "Pattern" and is actually:
%%PATTERN:Passing%%
</div>

Which gives us a Creative 300×250 in size with a Blue border with text inside it showing what information has been passed to it (in this case, it should be word “Pattern”):


 

Superficial Value

Superficial value allows you to pass information without impacting anything else. For example, I might use a attribute called “Info”. “Info” has no purpose in determine what Line Item should be shown so all Line Items will use the criteria “Info DOES NOT EQUAL AAAAAA” (AAAAAA being a value I will never use). Then you can pass whatever information to the attribute “Info” and use the the appropiate Macro in DFP to access that data.

Here’s a quick example:

Add the following Javascript in your DFP Header Tag. Find:

<script type='text/javascript'>
GA_googleFetchAds();
</script>

and add above:

<script language="JavaScript">
GA_googleAddAttr("Passing", "Undefined");
</script>

The above code puts an attribute “Passing” with the value “Undefined” as default.

Take a look at the bottom of the page where the actual ad is shown and see the data being passed into the Creative

The Line Item settings is:

dfp-pattern-superficial

ADVERTISING

I have the Targeting criteria set so that the Line Item will show when it’s NOT “Passing” or “Javascript”. You can use whatever value you want. The reason I want it to be not “Passing” or “Javascript” is because I have Line Items for those two already. So, this Line Item will show on all pages which have the attribute “Passing” on it and has a value that does not equal to “Passing” or “Javascript”.

You may wish to simply create a Free-Form Custom Targeting
(Inventory -> Custom Targeting -> New Key -> Values = Can I pass custom variables into a tag?).
And in your Line Items, make it so that the key does not equal a value you won’t use (so that it will effectively deliver on all your pages since that condition will always be true).

And the Creative:

<div style="width:300px; height:250px; padding: 20px; border: red solid 2px;">
DFP Passing attribute has the value: %%PATTERN:Passing%%
</div>

Which gives us a Creative 300×250 in size with a Red border with text inside it showing what information has been passed to it via the attribute “Passing”:

pattern_creative_result_no_passing

Conclusion

You can utilize this knowledge to pass in information to your Creative. You can mix and match both methods, utilize Javascript or a server-side language such as PHP to create a fairly flexible system of passing important information.

 


Next Step: DFP Small Business Line Item Settings Explained
Previous Step: How to create a Basic Cascade with DFP Small Business


Posted by Michael ScheelLast Updated: 19.07.2011