How to pass Information to DFP Small Business by using Patterns

< DFP Small Business Tutorial

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:

And the Creative:

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

Which gives us a Creative 300×250 in size with a Blue border and 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 an 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:

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;">
<p>DFP Passing attribute has the value: %%PATTERN:Passing%%</p>
</div>

Which gives us a Creative 300×250 in size with a Red border, and text inside it showing
what information has been passed to it via the attribute “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.

< DFP Small Business Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *

*