Home

Awesome

Build Status

Setup Tool for Prebid and GAM (previously DFP)

An automated line item generator for Prebid.js and Google Ad Manager (previously DFP)

Overview

When setting up Prebid, your ad ops team often has to create hundreds of line items in Google Ad Manager (GAM).

This tool automates setup for new header bidding partners. You define the advertiser, placements or ad units, and Prebid settings; then, it creates an order with one line item per price level, attaches creatives, sets placement and/or ad units, and Prebid key-value targeting.

While this tool covers typical use cases, it might not fit your needs. Check out the limitations before you dive in.

Note: Doubleclick for Publishers (DFP) was recently renamed to Google Ad Manager (GAM), so this repository may refer to GAM as DFP.

Getting Started

Requirements

Creating Google Credentials

You will need credentials to access your GAM account programmatically. This summarizes steps from GAM docs and the Google Ads Python libary auth guide.

  1. If you haven't yet, sign up for a GAM account.
  2. Create Google developer credentials
    • Go to the Google Developers Console Credentials page.
    • On the Credentials page, select Create credentials, then select Service account key.
    • Select New service account, and select JSON key type. You can leave the role blank.
    • Click Create to download a file containing a .json private key.
  3. Enable API access to GAM
    • Sign into your GAM account. You must have admin rights.
    • In the Admin section, select Global settings
    • Ensure that API access is enabled.
    • Click the Add a service account user button.
      • Use the service account email for the Google developer credentials you created above.
      • Set the role to "Administrator".
      • Click Save.

Setting Up

  1. Clone this repository.
  2. Install Python dependencies
    • Run pip install -r requirements.txt
    • Important: Python version 3.6 or higher is required.
  3. Rename key
    • Rename the Google credentials key you previously downloaded ([something].json) to key.json and move it to the root of this repository
  4. Make a copy of googleads.example.yaml and name it googleads.yaml.
  5. In googleads.yaml, set the required fields:
    • application_name is the name of the Google project you created when creating the service account credentials. It should appear in the top-left of the credentials page.
    • network_code is your GAM network number; e.g., for https://admanager.google.com/12398712#delivery, the network code is 12398712.

Verifying Setup

Let's try it out! From the top level directory, run

python -m dfp.get_orders

and you should see all of the orders in your GAM account.

Creating Line Items

Modify the following settings in settings.py:

SettingDescriptionType
DFP_ORDER_NAMEWhat you want to call your new GAM orderstring
DFP_USER_EMAIL_ADDRESSThe email of the GAM user who will be the trafficker for the created orderstring
DFP_ADVERTISER_NAMEThe name of the GAM advertiser for the created orderstring
DFP_TARGETED_AD_UNIT_NAMESThe names of GAM ad units the line items should targetarray of strings
DFP_TARGETED_PLACEMENT_NAMESThe names of GAM placements the line items should targetarray of strings
DFP_PLACEMENT_SIZESThe creative sizes for the targeted placementsarray of objects (e.g., [{'width': '728', 'height': '90'}])
PREBID_BIDDER_CODEThe value of hb_bidder for this partnerstring
PREBID_PRICE_BUCKETSThe price granularity; used to set hb_pb for each line item. Can use Prebid standard granularities such as medium or dense, a single custom CPM bucket object or an array of custom CPM bucket objectsobject, array or string
DFP_VIDEO_AD_TYPESet to true to create video ad units and creativesboolean
DFP_VAST_REDIRECT_URLThe redirect URL to use for video ad creatives (only used if DFP_VIDEO_AD_TYPE is set to True)string

Then, from the root of the repository, run:

python -m tasks.add_new_prebid_partner

You should be all set! Review your order, line items, and creatives to make sure they are correct. Then, approve the order in GAM.

Note: GAM might show a "Needs creatives" warning on the order for ~15 minutes after order creation. Typically, the warning is incorrect and will disappear on its own.

Additional Settings

In most cases, you won't need to modify these settings.

SettingDescriptionDefault
DFP_CREATE_ADVERTISER_IF_DOES_NOT_EXISTWhether we should create the advertiser with DFP_ADVERTISER_NAME in GAM if it does not existFalse
DFP_USE_EXISTING_ORDER_IF_EXISTSWhether we should modify an existing order if one already exists with name DFP_ORDER_NAMEFalse
DFP_NUM_CREATIVES_PER_LINE_ITEMThe number of duplicate creatives to attach to each line item. Due to GAM limitations, this should be equal to or greater than the number of ad units you serve on a given page.the length of setting DFP_TARGETED_PLACEMENT_NAMES
DFP_CURRENCY_CODEThe currency to use in line items.'USD'
DFP_LINE_ITEM_FORMATThe format for the line item names.u'{bidder_code}: HB ${price}'

Limitations

Please consider contributing to make the tool more flexible.

Contributors

Thanks to these people for making this tool better 🤗:

@sebmil-daily, @couhie, @dlackty, @pbrisson, @jsonUK