An automated line item generator for Google Ad Manager (previously DFP)
Clone this repository and follow 3 major steps to create 425 line items in Google Ad Manager for AIRIS.
- Creat Google Credentials
- Creating a Placement in Google Ad Manager
- Input Configuration and run the code
- Go to the Google Developers Console Credentials page.
- On the Credentials page, select Create credentials, then select Service account key.
- Click the dropdown menu under Service account.
- Select New service account
- Set up the service account name, leave the role blank, and select JSON key type.
- Click Create to download a file containing a
.json
private key. Click CREATE WITHOUT ROLE when you see the dialogue. - Rename the private key (
[something].json
) tokey.json
and move it to the root of this repository
- Enable API access to Google Ad Manager
- Sign into your Google Ad Manager. 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.
- Set up the service account user.
- Create a Placement in Google Ad manager
- From the root of the repository, set up python3 development environment.
- Run
pip install -r requirements.txt
. - Make a copy of
googleads.example.yaml
and name itgoogleads.yaml
. - 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., forhttps://admanager.google.com/12398712#delivery
, the network code is12398712
.
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.
If you see the error message, ValueError: unknown locale: UTF-8
, please run
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
and try again.
- Make a copy of
local_settings.example.py
and name itlocal_settings.py
. - Modify the following settings in
local_settings.py
:
Setting | Description | Type |
---|---|---|
DFP_ORDER_NAME |
What you want to call this order | string (e.g., 'dfpordername' ) |
DFP_USER_EMAIL_ADDRESS |
The service account email for the Google developer credentials you created above | string (e.g., 'email@email.com' ) |
DFP_ADVERTISER_NAME |
The service account name for the Google developer credentials you created above | string (e.g., 'advertisername' ) |
DFP_TARGETED_PLACEMENT_NAMES |
The names of GAM placements you created above | array of strings (e.g., ['placementname'] ) |
DFP_PLACEMENT_SIZES |
The creative sizes of all ad units specified in the configuration csv you uploaded | array of objects (e.g., [{'width': '728', 'height': '90'}] ) |
DFP_CURRENCY_CODE |
New Taiwan Dollar: ‘TWD' United States Dollar: ‘USD’ Japanese Yen: ‘JPY’ The currency settings is in the Global Settings of Google Ad Manager |
string |
DFP_NUM_CREATIVES_PER_LINE_ITEM |
Maximum Ad Units on any given webpage of your website | number |
Run:
python -m tasks.add_new_prebid_partner
After running successfully, you will see this message
Happy bidding!
Then, approve the order in Google Ad Manager.
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.
- This tool does not currently support run-of-network line items (see #16). You must target line items to placements, ad units, or both.
- Currently, the names of the bidder code targeting key (
hb_bidder
) and price bucket targeting key (hb_pb
) are not customizable. Thehb_bidder
targeting key is currently required (see #18) - This tool does not support additional line item targeting beyond placement, ad units,
hb_bidder
, andhb_pb
values.
- This tool does not modify existing orders or line items, it only creates them. If you need to make a change to an order, it's easiest to archive the existing order and recreate it.
Please consider contributing to make the tool more flexible.