A mobile ad tag contains all the information required for a mobile ad request that you can insert onto your webpage or application.
-
On the Inventory tab, click Generate tags in the side panel, or navigate down to the Settings tab of an ad unit and click Generate tags under the ad unit name at the top of the display.
-
From the Target Platform drop down, select Mobile.
-
Select ad units for which you want to generate ad tags by clicking include next to each one.
-
Click Generate tags.
-
Copy and paste the snippets from the resulting dialog.
-
Application ad units: Copy the ad unit ID and ad unit size into your application code.
-
Site ad units: Copy the header and document body code snippets into the <head> and <body> sections of your webpage, respectively.
-
Additional tagging guidelines
-
You can use the same ad unit multiple times on the same page, as long as you generate multiple tags, with different div IDs. You can't copy the same tagging snippet into the same page multiple times.
-
If you want to use iframe tags, please contact support.
-
The best way to debug a mobile tag is to use a developer tool like Firebug (in Firefox) to see if the ad slots are getting properly filled with creatives.
When generating tags using the individual tag generation dialog box (located on the ad unit page instead of the left side panel), you can copy and paste these units together to target multiple ad units on the same page.
Sample tag for ad unit 1
Sample tag for ad unit 2
Final tag: Paste a portion of tag 2 (highlighted) into tag 1
After you've defined the custom criteria in your network, you can target line items to key-values. You have to specify key-values in your ad tags if you want them available for targeting.
There are two ways to include custom key-values in your ad tags:
-
Hard-code the key-value in the ad tags so that the tag always includes that key-value. In this case, the tags are static and don't change dynamically.
-
Pass the key-values dynamically to the ad tags. Let's say that you maintain registration data for your users, so that when they sign up to use your site they provide you with their age and gender. Your webmaster can set it up so that when a user is signed in to your website, the information about their age and gender is passed dynamically to the ad tags, and then any line items that are targeted to their age or gender will serve to them.
Here are examples of how to hard-code 'Gender=Female' and 'Age=25' into your ad tag:
googletag.pubads().setTargeting('Gender','Female');
googletag.pubads().setTargeting('Age','25');
To define custom targeting for multiple ad units, declare a variable for each ad unit and assign custom targeting that is specific to that ad unit.
For example, to target ads to two ad units (sizes 300x50 and 250x250), define ad units and their properties as follows:
Make sure that custom targeting is defined before the line that says 'googletag.enableServices();'.
Here's an example of how to specify AdSense channel IDs in your mobile ad tag:
googletag.pubads().set("adsense_channel_ids", "27182820");
