Recently I had an advertiser running a direct campaign that wasn’t having great success. We decided if we could match the ad to specific pages, the results might be better.
Unfortunately, like many things in Google DFP – this was going to be complex to set-up. I got it working in the end, and the campaign had almost double the click through.
Why Target Specific URLs?
By default, when a line item is assigned to an ad unit, this will appear across the whole site (run of site). As most sites are based on templates or themes, the ad tags will be on every page (such as in a sidebar or header).
In some sites we may have ad units only serving on certain categories of page (such as a blog post, or a product page, etc).
But what if you want more fine-grained control, and hand-pick the pages the ad will appear on? This is called custom criteria, and it’s a bit of a pig to set-up.
Here’s how to do it:
1. Setup Targeting Criteria on Your Website
In this case we are setting criteria for the entire page (not an individual ad slot). We call a method called .setTargeting, assigning a key (I’ve called it “url”), and a value (the URL of the page).
googletag.defineSlot("/1234/travel/asia/food", [300, 250], "div-gpt-ad-123456789-1.addService(googletag.pubads()); // New line here googletag.pubads().setTargeting("url","/my-page-url"); // Before this line here googletag.pubads().enableSingleRequest();
It depends on your individual site as to how you come up with the URL name. I’m using WordPress, so this is what I do on a post.
<?php $url = parse_url(get_permalink($post_id)); $targeturl = substr($url['path'],0,40); ?> googletag.pubads().setTargeting("url","<?php echo $targeturl ?>"); googletag.enableServices();
Unfortunately DFP restricts criteria value to 40 characters, so the PHP code here will remove the hostname, and restrict to 40 characters. So if you have a massive URL, this is what will get generated.
If your URL is http://my-great-domain.com/my-really-awesome-page-name-1234-92424-why-are-URLs-so-long
The code will look like this:
This is just a limitation of DFP, so if you have massive URLs you may not be able have as fine-grained control as you wish.
2. Targeting Your DFP Line Item
First we need to setup the new custom targeting key:
- Open up DFP in your browser.
- Navigate to the Inventory tab.
- Select Custom Targeting, and click New Key.
- Name should be url, then click Add values.
- Into the box you can enter a large list of URLs and Apply.
- Then click Save.
Then assign the keys and values to the line item targeting:
- Go to your Line Item settings, and scroll down to Add targeting.
- Click on Custom criteria, then Add key.
- Type in url (the criteria key name you already setup in inventory).
- You can then quickly go through and check each URL you want to target (you can also free-form enter additional URLs).
- Make sure ALL URLs you want to target are entered into the single entry. Don’t add a new key record for each URL or else DFP will try to AND them together.
In order to test this, I had a dummy order and line item, and targeted them to an ad slot on a local developer site. I was then able to check the ad was only appearing on the URLs chosen.
The very stupid thing I did was to not stop this dummy campaign, and because I had the same ad slot on a live site – I served dummy ads on the live site for a few days. Oops.