Home / Tools / Google Ad Manager
✦ Google Ad Manager

GAM ad unit naming & key-values

Plan an ad unit hierarchy, generate every ad unit path from your sites, sections and positions, and check codes and key-values against Google Ad Manager's rules.

Ad unit hierarchy

Levels codes, one per line

Every combination becomes one ad unit: sites × sections × positions.

Ad units

Paths are in the form GPT uses in googletag.defineSlot(): /network code/level 1/level 2/…

Generated ad units

Key-values

Scope

GPT method

GPT targeting code


          

Run it before googletag.display(). Add the keys and values in Ad Manager to target them in line items.

Ad unit codes and key-values in Google Ad Manager

An ad unit path such as /1234567/examplenews/sports/top_banner is your network code followed by one ad unit code per level. Codes can be up to 100 characters and may only contain letters, numbers and _ - . * ! < : / ( ). They aren't case-sensitive, and they must be unique at the same level. An ad unit's code can't be changed after it's created, so settle the naming scheme first.

Ad Manager 360 has five levels of ad units; Ad Manager has two. Keep the hierarchy shallow and put details that change often, like article type or tags, into key-values instead of new ad units.

Key-values let line items target parts of your site. Keys are up to 20 characters, can't start with a number and can't contain spaces; values are up to 40 characters. Neither may contain " ' = ! + # ; ^ ( ) < > [ ] , * & ~ (* and ~ only work in dynamic key-values, for match types). Keys and values aren't case-sensitive. Never send personal data such as email addresses, phone numbers, names or precise locations in key-values.

Frequently asked questions

Which characters are allowed in a Google Ad Manager ad unit code?

Letters, numbers, underscores, hyphens, periods, asterisks, exclamation marks, left angle brackets, colons, forward slashes and parentheses. Codes can be up to 100 characters and aren't case-sensitive.

How many levels can an ad unit hierarchy have?

Google Ad Manager 360 has five levels of ad units; Google Ad Manager has two. The network code in front of the path isn't one of them.

Can two ad units have the same code?

Not at the same level. The same code can be reused at different levels, for example top_banner under several sections, unless they're Ad Exchange ad units. Because codes aren't case-sensitive, Sports and sports count as the same code.

What are the limits for Ad Manager key-values?

Keys can be up to 20 characters and values up to 40. Keys can't start with a number or contain spaces. These characters are reserved in keys and values: " ' = ! + # ; ^ ( ) < > [ ] , * & ~. A network can have 200 active keys.

Can I pass a user's email or ID in a key-value?

No. Your Ad Manager contract doesn't allow passing personally identifiable information to Google, such as email addresses, phone numbers, full names or usernames, mailing addresses or precise locations. Use categories such as section=sports instead.

Should I use setTargeting or setConfig in GPT?

Google now documents googletag.setConfig({ targeting }) for page-level and slot.setConfig({ targeting }) for slot-level key-values; setTargeting is marked deprecated. Both snippets are offered here for older setups.

Related guides

More free tools