GithubHelp home page GithubHelp logo

kmjennison / dfp-prebid-setup Goto Github PK

View Code? Open in Web Editor NEW
116.0 21.0 73.0 221 KB

Automated line item generator for Prebid.js and Google Ad Manager

License: MIT License

Python 99.72% HTML 0.28%
prebid advertising header-bidding google-ad-manager gam doubleclick dfp doubleclick-for-publishers

dfp-prebid-setup's Introduction

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

  • Python version >= 3.6 and a basic knowledge of Python
  • Access to create a service account in the Google Developers Console
  • Admin access to your Google Ad Manager account

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:

Setting Description Type
DFP_ORDER_NAME What you want to call your new GAM order string
DFP_USER_EMAIL_ADDRESS The email of the GAM user who will be the trafficker for the created order string
DFP_ADVERTISER_NAME The name of the GAM advertiser for the created order string
DFP_TARGETED_AD_UNIT_NAMES The names of GAM ad units the line items should target array of strings
DFP_TARGETED_PLACEMENT_NAMES The names of GAM placements the line items should target array of strings
DFP_PLACEMENT_SIZES The creative sizes for the targeted placements array of objects (e.g., [{'width': '728', 'height': '90'}])
PREBID_BIDDER_CODE The value of hb_bidder for this partner string
PREBID_PRICE_BUCKETS The 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 objects object, array or string
DFP_VIDEO_AD_TYPE Set to true to create video ad units and creatives boolean
DFP_VAST_REDIRECT_URL The 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.

Setting Description Default
DFP_CREATE_ADVERTISER_IF_DOES_NOT_EXIST Whether we should create the advertiser with DFP_ADVERTISER_NAME in GAM if it does not exist False
DFP_USE_EXISTING_ORDER_IF_EXISTS Whether we should modify an existing order if one already exists with name DFP_ORDER_NAME False
DFP_NUM_CREATIVES_PER_LINE_ITEM The 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_CODE The currency to use in line items. 'USD'
DFP_LINE_ITEM_FORMAT The format for the line item names. u'{bidder_code}: HB ${price}'

Limitations

  • 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. The hb_bidder targeting key is currently required (see #18)
  • This tool does not support additional line item targeting beyond placement, ad units, hb_bidder, and hb_pb values. It does not yet support setting other options on the line item such as the "Allow same advertiser exception" (see #59)
  • The price bucketing setting PREBID_PRICE_BUCKETS only allows for uniform bucketing (see #27). For example, you can create $0.01 buckets from $0 - $20, but you cannot specify $0.01 buckets from $0 - $5 and $0.50 buckets from $5 - $20. Using entirely $0.01 buckets will still work for the custom buckets—you'll just have more line items than you need.
  • 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.

Contributors

Thanks to these people for making this tool better 🤗:

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

dfp-prebid-setup's People

Contributors

couhie avatar dependabot[bot] avatar dlackty avatar jasonpubc avatar jsonuk avatar kmjennison avatar lucop1 avatar mxra8 avatar pbrisson avatar pinkiebala avatar sebmil-daily avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dfp-prebid-setup's Issues

Something going wrong when implement the guid

Hi guys,

I have tried to implement mentioned hack, but it doesn't work.
I have faced with the following error (attached):

`Going to create 301 new line items.
Order: Prebid_name
Advertiser: name
Owner: [email protected]

Line items will have targeting:
  hb_pb = 0.00, 0.05, 0.10, ... 14.90, 14.95, 15.00
  hb_bidder = appnexus
  placements = []

Is this correct? (y/n)
y
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/Documents/API_AD/tasks/add_new_prebid_partner.py", line 435, in
main()
File "/Users/Documents/API_AD/tasks/add_new_prebid_partner.py", line 431, in main
currency_code,
File "/Users/Documents/API_AD/tasks/add_new_prebid_partner.py", line 61, in setup_partner
user_id = dfp.get_users.get_user_id_by_email(user_email)
File "/Users/Documents/API_AD/dfp/get_users.py", line 24, in get_user_id_by_email
user_service = dfp_client.GetService('UserService', version='v201802')
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/googleads/dfp.py", line 287, in GetService
cache=self.cache)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/googleads/common.py", line 1125, in init
endpoint, transport=transport, plugins=plugins)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/zeep/client.py", line 62, in init
wsdl, self.transport, settings=self.settings)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/zeep/wsdl/wsdl.py", line 82, in init
document = self._get_xml_document(location)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/zeep/wsdl/wsdl.py", line 143, in _get_xml_document
location, self.transport, self.location, settings=self.settings)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/zeep/loader.py", line 74, in load_external
content = transport.load(url)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/zeep/transports.py", line 113, in load
self.cache.add(url, content)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/zeep/cache.py", line 103, in add
cursor.execute("DELETE FROM request WHERE url = ?", (url,))
sqlite3.OperationalError: attempt to write a readonly database`

Can you support me how can I fix it?

error in "pip install -r requirements.txt"

Running Windows 10, Python36-32

When executing "pip install -r requirements.txt", it gets to a point in the process where it errors. The following output is from the Windows command prompt window. I'd like to know what's the issue.

Running setup.py install for pycrypto ... error
Complete output from command "c:\program files (x86)\python36-32\python.exe" -u -c "import setuptools, tokenize;file='C:\Users\aelta\AppData\Local\Temp\pip-build-o8krojmi\pycrypto\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\aelta\AppData\Local\Temp\pip-ks92zdm7-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win32-3.6
creating build\lib.win32-3.6\Crypto
copying lib\Crypto\pct_warnings.py -> build\lib.win32-3.6\Crypto
copying lib\Crypto_init_.py -> build\lib.win32-3.6\Crypto
creating build\lib.win32-3.6\Crypto\Hash
copying lib\Crypto\Hash\hashalgo.py -> build\lib.win32-3.6\Crypto\Hash
copying lib\Crypto\Hash\HMAC.py -> build\lib.win32-3.6\Crypto\Hash
copying lib\Crypto\Hash\MD2.py -> build\lib.win32-3.6\Crypto\Hash
copying lib\Crypto\Hash\MD4.py -> build\lib.win32-3.6\Crypto\Hash
copying lib\Crypto\Hash\MD5.py -> build\lib.win32-3.6\Crypto\Hash
copying lib\Crypto\Hash\RIPEMD.py -> build\lib.win32-3.6\Crypto\Hash
copying lib\Crypto\Hash\SHA.py -> build\lib.win32-3.6\Crypto\Hash
copying lib\Crypto\Hash\SHA224.py -> build\lib.win32-3.6\Crypto\Hash
copying lib\Crypto\Hash\SHA256.py -> build\lib.win32-3.6\Crypto\Hash
copying lib\Crypto\Hash\SHA384.py -> build\lib.win32-3.6\Crypto\Hash
copying lib\Crypto\Hash\SHA512.py -> build\lib.win32-3.6\Crypto\Hash
copying lib\Crypto\Hash_init_.py -> build\lib.win32-3.6\Crypto\Hash
creating build\lib.win32-3.6\Crypto\Cipher
copying lib\Crypto\Cipher\AES.py -> build\lib.win32-3.6\Crypto\Cipher
copying lib\Crypto\Cipher\ARC2.py -> build\lib.win32-3.6\Crypto\Cipher
copying lib\Crypto\Cipher\ARC4.py -> build\lib.win32-3.6\Crypto\Cipher
copying lib\Crypto\Cipher\blockalgo.py -> build\lib.win32-3.6\Crypto\Cipher
copying lib\Crypto\Cipher\Blowfish.py -> build\lib.win32-3.6\Crypto\Cipher
copying lib\Crypto\Cipher\CAST.py -> build\lib.win32-3.6\Crypto\Cipher
copying lib\Crypto\Cipher\DES.py -> build\lib.win32-3.6\Crypto\Cipher
copying lib\Crypto\Cipher\DES3.py -> build\lib.win32-3.6\Crypto\Cipher
copying lib\Crypto\Cipher\PKCS1_OAEP.py -> build\lib.win32-3.6\Crypto\Cipher
copying lib\Crypto\Cipher\PKCS1_v1_5.py -> build\lib.win32-3.6\Crypto\Cipher
copying lib\Crypto\Cipher\XOR.py -> build\lib.win32-3.6\Crypto\Cipher
copying lib\Crypto\Cipher_init_.py -> build\lib.win32-3.6\Crypto\Cipher
creating build\lib.win32-3.6\Crypto\Util
copying lib\Crypto\Util\asn1.py -> build\lib.win32-3.6\Crypto\Util
copying lib\Crypto\Util\Counter.py -> build\lib.win32-3.6\Crypto\Util
copying lib\Crypto\Util\number.py -> build\lib.win32-3.6\Crypto\Util
copying lib\Crypto\Util\py3compat.py -> build\lib.win32-3.6\Crypto\Util
copying lib\Crypto\Util\randpool.py -> build\lib.win32-3.6\Crypto\Util
copying lib\Crypto\Util\RFC1751.py -> build\lib.win32-3.6\Crypto\Util
copying lib\Crypto\Util\winrandom.py -> build\lib.win32-3.6\Crypto\Util
copying lib\Crypto\Util_number_new.py -> build\lib.win32-3.6\Crypto\Util
copying lib\Crypto\Util_init_.py -> build\lib.win32-3.6\Crypto\Util
creating build\lib.win32-3.6\Crypto\Random
copying lib\Crypto\Random\random.py -> build\lib.win32-3.6\Crypto\Random
copying lib\Crypto\Random_UserFriendlyRNG.py -> build\lib.win32-3.6\Crypto\Random
copying lib\Crypto\Random_init_.py -> build\lib.win32-3.6\Crypto\Random
creating build\lib.win32-3.6\Crypto\Random\Fortuna
copying lib\Crypto\Random\Fortuna\FortunaAccumulator.py -> build\lib.win32-3.6\Crypto\Random\Fortuna
copying lib\Crypto\Random\Fortuna\FortunaGenerator.py -> build\lib.win32-3.6\Crypto\Random\Fortuna
copying lib\Crypto\Random\Fortuna\SHAd256.py -> build\lib.win32-3.6\Crypto\Random\Fortuna
copying lib\Crypto\Random\Fortuna_init_.py -> build\lib.win32-3.6\Crypto\Random\Fortuna
creating build\lib.win32-3.6\Crypto\Random\OSRNG
copying lib\Crypto\Random\OSRNG\fallback.py -> build\lib.win32-3.6\Crypto\Random\OSRNG
copying lib\Crypto\Random\OSRNG\nt.py -> build\lib.win32-3.6\Crypto\Random\OSRNG
copying lib\Crypto\Random\OSRNG\posix.py -> build\lib.win32-3.6\Crypto\Random\OSRNG
copying lib\Crypto\Random\OSRNG\rng_base.py -> build\lib.win32-3.6\Crypto\Random\OSRNG
copying lib\Crypto\Random\OSRNG_init_.py -> build\lib.win32-3.6\Crypto\Random\OSRNG
creating build\lib.win32-3.6\Crypto\SelfTest
copying lib\Crypto\SelfTest\st_common.py -> build\lib.win32-3.6\Crypto\SelfTest
copying lib\Crypto\SelfTest_init_.py -> build\lib.win32-3.6\Crypto\SelfTest
creating build\lib.win32-3.6\Crypto\SelfTest\Cipher
copying lib\Crypto\SelfTest\Cipher\common.py -> build\lib.win32-3.6\Crypto\SelfTest\Cipher
copying lib\Crypto\SelfTest\Cipher\test_AES.py -> build\lib.win32-3.6\Crypto\SelfTest\Cipher
copying lib\Crypto\SelfTest\Cipher\test_ARC2.py -> build\lib.win32-3.6\Crypto\SelfTest\Cipher
copying lib\Crypto\SelfTest\Cipher\test_ARC4.py -> build\lib.win32-3.6\Crypto\SelfTest\Cipher
copying lib\Crypto\SelfTest\Cipher\test_Blowfish.py -> build\lib.win32-3.6\Crypto\SelfTest\Cipher
copying lib\Crypto\SelfTest\Cipher\test_CAST.py -> build\lib.win32-3.6\Crypto\SelfTest\Cipher
copying lib\Crypto\SelfTest\Cipher\test_DES.py -> build\lib.win32-3.6\Crypto\SelfTest\Cipher
copying lib\Crypto\SelfTest\Cipher\test_DES3.py -> build\lib.win32-3.6\Crypto\SelfTest\Cipher
copying lib\Crypto\SelfTest\Cipher\test_pkcs1_15.py -> build\lib.win32-3.6\Crypto\SelfTest\Cipher
copying lib\Crypto\SelfTest\Cipher\test_pkcs1_oaep.py -> build\lib.win32-3.6\Crypto\SelfTest\Cipher
copying lib\Crypto\SelfTest\Cipher\test_XOR.py -> build\lib.win32-3.6\Crypto\SelfTest\Cipher
copying lib\Crypto\SelfTest\Cipher_init_.py -> build\lib.win32-3.6\Crypto\SelfTest\Cipher
creating build\lib.win32-3.6\Crypto\SelfTest\Hash
copying lib\Crypto\SelfTest\Hash\common.py -> build\lib.win32-3.6\Crypto\SelfTest\Hash
copying lib\Crypto\SelfTest\Hash\test_HMAC.py -> build\lib.win32-3.6\Crypto\SelfTest\Hash
copying lib\Crypto\SelfTest\Hash\test_MD2.py -> build\lib.win32-3.6\Crypto\SelfTest\Hash
copying lib\Crypto\SelfTest\Hash\test_MD4.py -> build\lib.win32-3.6\Crypto\SelfTest\Hash
copying lib\Crypto\SelfTest\Hash\test_MD5.py -> build\lib.win32-3.6\Crypto\SelfTest\Hash
copying lib\Crypto\SelfTest\Hash\test_RIPEMD.py -> build\lib.win32-3.6\Crypto\SelfTest\Hash
copying lib\Crypto\SelfTest\Hash\test_SHA.py -> build\lib.win32-3.6\Crypto\SelfTest\Hash
copying lib\Crypto\SelfTest\Hash\test_SHA224.py -> build\lib.win32-3.6\Crypto\SelfTest\Hash
copying lib\Crypto\SelfTest\Hash\test_SHA256.py -> build\lib.win32-3.6\Crypto\SelfTest\Hash
copying lib\Crypto\SelfTest\Hash\test_SHA384.py -> build\lib.win32-3.6\Crypto\SelfTest\Hash
copying lib\Crypto\SelfTest\Hash\test_SHA512.py -> build\lib.win32-3.6\Crypto\SelfTest\Hash
copying lib\Crypto\SelfTest\Hash_init_.py -> build\lib.win32-3.6\Crypto\SelfTest\Hash
creating build\lib.win32-3.6\Crypto\SelfTest\Protocol
copying lib\Crypto\SelfTest\Protocol\test_AllOrNothing.py -> build\lib.win32-3.6\Crypto\SelfTest\Protocol
copying lib\Crypto\SelfTest\Protocol\test_chaffing.py -> build\lib.win32-3.6\Crypto\SelfTest\Protocol
copying lib\Crypto\SelfTest\Protocol\test_KDF.py -> build\lib.win32-3.6\Crypto\SelfTest\Protocol
copying lib\Crypto\SelfTest\Protocol\test_rfc1751.py -> build\lib.win32-3.6\Crypto\SelfTest\Protocol
copying lib\Crypto\SelfTest\Protocol_init_.py -> build\lib.win32-3.6\Crypto\SelfTest\Protocol
creating build\lib.win32-3.6\Crypto\SelfTest\PublicKey
copying lib\Crypto\SelfTest\PublicKey\test_DSA.py -> build\lib.win32-3.6\Crypto\SelfTest\PublicKey
copying lib\Crypto\SelfTest\PublicKey\test_ElGamal.py -> build\lib.win32-3.6\Crypto\SelfTest\PublicKey
copying lib\Crypto\SelfTest\PublicKey\test_importKey.py -> build\lib.win32-3.6\Crypto\SelfTest\PublicKey
copying lib\Crypto\SelfTest\PublicKey\test_RSA.py -> build\lib.win32-3.6\Crypto\SelfTest\PublicKey
copying lib\Crypto\SelfTest\PublicKey_init_.py -> build\lib.win32-3.6\Crypto\SelfTest\PublicKey
creating build\lib.win32-3.6\Crypto\SelfTest\Random
copying lib\Crypto\SelfTest\Random\test_random.py -> build\lib.win32-3.6\Crypto\SelfTest\Random
copying lib\Crypto\SelfTest\Random\test_rpoolcompat.py -> build\lib.win32-3.6\Crypto\SelfTest\Random
copying lib\Crypto\SelfTest\Random\test__UserFriendlyRNG.py -> build\lib.win32-3.6\Crypto\SelfTest\Random
copying lib\Crypto\SelfTest\Random_init_.py -> build\lib.win32-3.6\Crypto\SelfTest\Random
creating build\lib.win32-3.6\Crypto\SelfTest\Random\Fortuna
copying lib\Crypto\SelfTest\Random\Fortuna\test_FortunaAccumulator.py -> build\lib.win32-3.6\Crypto\SelfTest\Random\Fortuna
copying lib\Crypto\SelfTest\Random\Fortuna\test_FortunaGenerator.py -> build\lib.win32-3.6\Crypto\SelfTest\Random\Fortuna
copying lib\Crypto\SelfTest\Random\Fortuna\test_SHAd256.py -> build\lib.win32-3.6\Crypto\SelfTest\Random\Fortuna
copying lib\Crypto\SelfTest\Random\Fortuna_init_.py -> build\lib.win32-3.6\Crypto\SelfTest\Random\Fortuna
creating build\lib.win32-3.6\Crypto\SelfTest\Random\OSRNG
copying lib\Crypto\SelfTest\Random\OSRNG\test_fallback.py -> build\lib.win32-3.6\Crypto\SelfTest\Random\OSRNG
copying lib\Crypto\SelfTest\Random\OSRNG\test_generic.py -> build\lib.win32-3.6\Crypto\SelfTest\Random\OSRNG
copying lib\Crypto\SelfTest\Random\OSRNG\test_nt.py -> build\lib.win32-3.6\Crypto\SelfTest\Random\OSRNG
copying lib\Crypto\SelfTest\Random\OSRNG\test_posix.py -> build\lib.win32-3.6\Crypto\SelfTest\Random\OSRNG
copying lib\Crypto\SelfTest\Random\OSRNG\test_winrandom.py -> build\lib.win32-3.6\Crypto\SelfTest\Random\OSRNG
copying lib\Crypto\SelfTest\Random\OSRNG_init_.py -> build\lib.win32-3.6\Crypto\SelfTest\Random\OSRNG
creating build\lib.win32-3.6\Crypto\SelfTest\Util
copying lib\Crypto\SelfTest\Util\test_asn1.py -> build\lib.win32-3.6\Crypto\SelfTest\Util
copying lib\Crypto\SelfTest\Util\test_Counter.py -> build\lib.win32-3.6\Crypto\SelfTest\Util
copying lib\Crypto\SelfTest\Util\test_number.py -> build\lib.win32-3.6\Crypto\SelfTest\Util
copying lib\Crypto\SelfTest\Util\test_winrandom.py -> build\lib.win32-3.6\Crypto\SelfTest\Util
copying lib\Crypto\SelfTest\Util_init_.py -> build\lib.win32-3.6\Crypto\SelfTest\Util
creating build\lib.win32-3.6\Crypto\SelfTest\Signature
copying lib\Crypto\SelfTest\Signature\test_pkcs1_15.py -> build\lib.win32-3.6\Crypto\SelfTest\Signature
copying lib\Crypto\SelfTest\Signature\test_pkcs1_pss.py -> build\lib.win32-3.6\Crypto\SelfTest\Signature
copying lib\Crypto\SelfTest\Signature_init_.py -> build\lib.win32-3.6\Crypto\SelfTest\Signature
creating build\lib.win32-3.6\Crypto\Protocol
copying lib\Crypto\Protocol\AllOrNothing.py -> build\lib.win32-3.6\Crypto\Protocol
copying lib\Crypto\Protocol\Chaffing.py -> build\lib.win32-3.6\Crypto\Protocol
copying lib\Crypto\Protocol\KDF.py -> build\lib.win32-3.6\Crypto\Protocol
copying lib\Crypto\Protocol_init_.py -> build\lib.win32-3.6\Crypto\Protocol
creating build\lib.win32-3.6\Crypto\PublicKey
copying lib\Crypto\PublicKey\DSA.py -> build\lib.win32-3.6\Crypto\PublicKey
copying lib\Crypto\PublicKey\ElGamal.py -> build\lib.win32-3.6\Crypto\PublicKey
copying lib\Crypto\PublicKey\pubkey.py -> build\lib.win32-3.6\Crypto\PublicKey
copying lib\Crypto\PublicKey\RSA.py -> build\lib.win32-3.6\Crypto\PublicKey
copying lib\Crypto\PublicKey_DSA.py -> build\lib.win32-3.6\Crypto\PublicKey
copying lib\Crypto\PublicKey_RSA.py -> build\lib.win32-3.6\Crypto\PublicKey
copying lib\Crypto\PublicKey_slowmath.py -> build\lib.win32-3.6\Crypto\PublicKey
copying lib\Crypto\PublicKey_init_.py -> build\lib.win32-3.6\Crypto\PublicKey
creating build\lib.win32-3.6\Crypto\Signature
copying lib\Crypto\Signature\PKCS1_PSS.py -> build\lib.win32-3.6\Crypto\Signature
copying lib\Crypto\Signature\PKCS1_v1_5.py -> build\lib.win32-3.6\Crypto\Signature
copying lib\Crypto\Signature_init_.py -> build\lib.win32-3.6\Crypto\Signature
Skipping optional fixer: buffer
Skipping optional fixer: idioms
Skipping optional fixer: set_literal
Skipping optional fixer: ws_comma
running build_ext
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
building 'Crypto.Random.OSRNG.winrandom' extension
creating build\temp.win32-3.6
creating build\temp.win32-3.6\Release
creating build\temp.win32-3.6\Release\src
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Isrc/ -Isrc/inc-msvc/ "-Ic:\program files (x86)\python36-32\include" "-Ic:\program files (x86)\python36-32\include" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt" /Tcsrc/winrand.c /Fobuild\temp.win32-3.6\Release\src/winrand.obj
winrand.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(26): error C2061: syntax error: identifier 'intmax_t'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(27): error C2061: syntax error: identifier 'rem'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(27): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(28): error C2059: syntax error: '}'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(30): error C2061: syntax error: identifier 'imaxdiv_t'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(30): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(40): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2146: syntax error: missing ')' before identifier '_Number'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2061: syntax error: identifier '_Number'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(42): error C2059: syntax error: ')'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(45): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2146: syntax error: missing ')' before identifier '_Numerator'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2061: syntax error: identifier '_Numerator'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2059: syntax error: ','
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(48): error C2059: syntax error: ')'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(50): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(56): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(63): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(69): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(76): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(82): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(89): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(95): error C2143: syntax error: missing '{' before '__cdecl'
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe' failed with exit status 2

----------------------------------------

Command ""c:\program files (x86)\python36-32\python.exe" -u -c "import setuptools, tokenize;file='C:\Users\aelta\AppData\Local\Temp\pip-build-o8krojmi\pycrypto\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\aelta\AppData\Local\Temp\pip-ks92zdm7-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\aelta\AppData\Local\Temp\pip-build-o8krojmi\pycrypto\

Add TravisCI

Run automated tests with Python 2 and 3 for PRs.

ImportError: cannot import name ad_manager

Hi!

I downloaded the last version of the line item generator, but can't manage to make it work. I'm certainly missing something...

--
iMac-de-Eric:dfp2 xxx$ python -m dfp.get_orders
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Users/xxx/Prog/dfp2/dfp/get_orders.py", line 6, in
from googleads import ad_manager
ImportError: cannot import name ad_manager

--

Any idea?

Best,
Eric

URL Error broken pipe while creating line items

While at the "Creating line items" stage I was blocked by the following error.
This seems it could be a timeout issue with the DFP's API, is anyone else running into this issue? Any suggestions would be greatly appreciated.

Creating line items... Traceback (most recent call last): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/Users/lilliananishihiraCheatsheet/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 364, in <module> main() File "/Users/lilliananishihiraCheatsheet/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 360, in main currency_code, File "/Users/lilliananishihiraCheatsheet/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 92, in setup_partner creative_ids, size_overrides=sizes) File "dfp/associate_line_items_and_creatives.py", line 44, in make_licas licas = lica_service.createLineItemCreativeAssociations(licas) File "/Users/lilliananishihiraCheatsheet/Library/Python/2.7/lib/python/site-packages/googleads/common.py", line 779, in MakeSoapRequest self._packer) for arg in args]) File "/Users/lilliananishihiraCheatsheet/Library/Python/2.7/lib/python/site-packages/suds/client.py", line 521, in __call__ return client.invoke(args, kwargs) File "/Users/lilliananishihiraCheatsheet/Library/Python/2.7/lib/python/site-packages/suds/client.py", line 581, in invoke result = self.send(soapenv) File "/Users/lilliananishihiraCheatsheet/Library/Python/2.7/lib/python/site-packages/suds/client.py", line 613, in send reply = self.options.transport.send(request) File "/Users/lilliananishihiraCheatsheet/Library/Python/2.7/lib/python/site-packages/googleads/util.py", line 123, in PatchedHttpTransportSend fp = self.u2open(u2request) File "/Users/lilliananishihiraCheatsheet/Library/Python/2.7/lib/python/site-packages/suds/transport/http.py", line 132, in u2open return url.open(u2request, timeout=tm) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 431, in open response = self._open(req, data) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 449, in _open '_open', req) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain result = func(*args) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1240, in https_open context=self._context) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1197, in do_open raise URLError(err) urllib2.URLError: <urlopen error [Errno 32] Broken pipe>

Client Error: Not found for URL

I'm getting the following error running python -m dfp.get_orders:

$ python -m dfp.get_orders
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/perry/Temp/dfp-prebid-setup/dfp/get_orders.py", line 89, in <module>
    main()
  File "/home/perry/Temp/dfp-prebid-setup/dfp/get_orders.py", line 86, in main
    get_all_orders(print_orders=True)
  File "/home/perry/Temp/dfp-prebid-setup/dfp/get_orders.py", line 64, in get_all_orders
    order_service = dfp_client.GetService('OrderService', version='v201802')
  File "/home/perry/.local/lib/python2.7/site-packages/googleads/dfp.py", line 287, in GetService
    cache=self.cache)
  File "/home/perry/.local/lib/python2.7/site-packages/googleads/common.py", line 1129, in __init__
    raise googleads.errors.GoogleAdsSoapTransportError(str(e))
googleads.errors.GoogleAdsSoapTransportError: 404 Client Error: Not Found for url: https://ads.google.com/apis/ads/publisher/v201802/OrderService?wsdl

JSON key and account ID set correctly.

python -m tasks.add_new_prebid_partner, results in error '[CustomTargetingError.VALUE_NAME_DUPLICATE @ name; trigger:'0.03']'

Info on what you expected would happen, and what actually happened

When I run:
python -m tasks.add_new_prebid_partner

I get the following error:
suds.WebFault: Server raised fault: '[CustomTargetingError.VALUE_NAME_DUPLICATE @ name; trigger:'0.03']'

What I think the problem is:
The script does not want to run if the hb_pb key-values are already defined in DFP.

Details:
When I first ran the script, it started creating the targeting associations with the key values and then errored because I tried to generate 2000 line items for the single order. I went and fixed my settings.py and ran the script again and for some reason it won't work at all if the hb_pb key values are already set for the price bucket range you defined in settings.

As a test, I edited my settings.py to generate order / line items for values where I hadn't already defined hb_pb bids for, and it worked flawlessly. Any idea what is going on here?

Here is the entire error, starting from when i ran the command in terminal:
dfp-prebid-setup $python -m tasks.add_new_prebid_partner

Going to create 100 new line items.
  Order: Prebid_Test_1
  Advertiser: Prebid
  Owner: [redacted]

Line items will have targeting:
  hb_pb = 0.01, 0.02, 0.03, ... 0.98, 0.99, 1.00
  hb_bidder = hb_pb
  placements = ['Header', 'Footer']

Is this correct? (y/n)
y
Found user with email [redacted]
Found placement with ID "28519744" and name "Header".
Found placement with ID "28521000" and name "Footer".
Using existing advertiser with ID "30289002", name "Prebid", and type "ADVERTISER".
Created an order with id "2098258075"" and name "Prebid_Test_1".
Created creative with ID "138204353492" and name "hb_pb: HB Prebid_Test_1, #1".
Created creative with ID "138204353582" and name "hb_pb: HB Prebid_Test_1, #2".
Key "hb_bidder" exists and has 2 existing values.
Key "hb_pb" exists and has 500 existing values.
<suds.sax.document.Document instance at 0x10d519ea8>
Server raised fault in response.
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Users/.../dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 358, in
main()
File "/Users/.../dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 354, in main
currency_code,
File "/Users/.../dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 80, in setup_partner
currency_code, HBBidderValueGetter, HBPBValueGetter)
File "/Users/.../dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 189, in create_line_item_configs
hb_pb_value_id = HBPBValueGetter.get_value_id(price_str)
File "/Users/.../dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 136, in get_value_id
val_id = self._create_value_and_return_id(value_name)
File "/Users/.../dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 123, in _create_value_and_return_id
self.key_id)
File "dfp/create_custom_targeting.py", line 77, in create_targeting_value
values_config)
File "/usr/local/lib/python2.7/site-packages/googleads/common.py", line 700, in MakeSoapRequest
*[_PackForSuds(arg, self.suds_client.factory) for arg in args])
File "/usr/local/lib/python2.7/site-packages/suds/client.py", line 521, in call
return client.invoke(args, kwargs)
File "/usr/local/lib/python2.7/site-packages/suds/client.py", line 581, in invoke
result = self.send(soapenv)
File "/usr/local/lib/python2.7/site-packages/suds/client.py", line 619, in send
description=tostr(e), original_soapenv=original_soapenv)
File "/usr/local/lib/python2.7/site-packages/suds/client.py", line 670, in process_reply
raise WebFault(fault, replyroot)
suds.WebFault: Server raised fault: '[CustomTargetingError.VALUE_NAME_DUPLICATE @ name; trigger:'0.03']'

Your settings from settings.py, hiding any sensitive info

Default basic settings

Your Python version (python --version)

dfp-prebid-setup $python --version
Python 2.7.9

Support over 500 maximum value of prebid CPM.

If use an currency with a large CPM digit like Japan JPY, i want to set a value that over 500 for the maximum value of prebid.
I want the maximum value of prebid to be a large value over 500, such as 5000, or I want to be able to change it with an option.

python -m tasks.add_new_prebid_partner gives error

C:\dfp>python -m tasks.add_new_prebid_partner

Going to create �[1m201�[0m new line items.
  �[1mOrder�[0m: �[94mPrebid_SPH�[0m
  �[1mAdvertiser�[0m: �[94mSPHDigital�[0m
  �[1mOwner�[0m: �[[email protected]�[0m

Line items will have targeting:
  �[1mhb_pb�[0m = �[94m0.00, 0.10, 0.20, ... 19.80, 19.90, 20.00�[0m
  �[1mhb_bidder�[0m = �[94mhb_bidder�[0m
  �[1mplacements�[0m = �[94m['Prebid']�[0m

Traceback (most recent call last):
File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main
"main", mod_spec)
File "C:\Python34\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\dfp\tasks\add_new_prebid_partner.py", line 337, in
main()
File "C:\dfp\tasks\add_new_prebid_partner.py", line 320, in main
ok = raw_input('Is this correct? (y/n)\n')
NameError: name 'raw_input' is not defined

Activate all line items after creating a new order

For me, line items are set to "Inactive" status after creation, which requires then setting each of them active before they're ready for delivery. This might have been a change in DFP behavior.

We should include line item activation as part of the process of adding a new Prebid bidder.

DFP API Sunset -v201702

Just received a mail from DFP that the API version on which this is based is going to be deprecated on 30th March 2018. Do we have any plans to upgrade the API version that this tool is currently based on?

Ascii encoding fails because char is part of UTF most likely

Since DFP probably allows UTF-8 or 16?

Currently grabbing out orders fails.

Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/tomas/dev/dfp-prebid-setup/dfp/get_orders.py", line 85, in <module>
    main()
  File "/Users/tomas/dev/dfp-prebid-setup/dfp/get_orders.py", line 82, in main
    get_all_orders()
  File "/Users/tomas/dev/dfp-prebid-setup/dfp/get_orders.py", line 76, in get_all_orders
    id=order['id'], name=order['name']))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 18: ordinal not in range(128)

python -m tasks.add_new_prebid_partner gives error

Traceback (most recent call last):

File "C:\Python27\lib\runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in run_code
exec code in run_globals
File "C:\DFP\tasks\add_new_prebid_partner.py", line 337, in
main()
File "C:\DFP\tasks\add_new_prebid_partner.py", line 333, in main
prices,
File "C:\DFP\tasks\add_new_prebid_partner.py", line 65, in setup_partner
hb_bidder_key_id = get_or_create_dfp_targeting_key('hb_bidder')
File "C:\DFP\tasks\add_new_prebid_partner.py", line 144, in get_or_create_dfp

targeting_key
key_id = dfp.get_custom_targeting.get_key_id_by_name(name)
File "dfp\get_custom_targeting.py", line 44, in get_key_id_by_name
return key['id']
TypeError: 'NoneType' object has no attribute 'getitem'

Cannot create order due to duplicate archived name

After I ran this tool, I realized one of the configurations I've set was incorrect so I archived the created the orders in DFP, adjusted the config, and then started the process again. Unfortunately, there seems to be an issue in re-creating the same orders using the same names I've used previously, even though it was archived. Anyone seen this issue before and know how to get around it?

python -m dfp.get_orders gives error

python -m dfp.get_orders
Traceback (most recent call last):
File "C:\Python34\lib\runpy.py", line 151, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name)
File "C:\Python34\lib\runpy.py", line 126, in _get_module_details
code = loader.get_code(mod_name)
File "", line 1572, in get_code
File "", line 1532, in source_to_code
File "", line 321, in _call_with_frames_removed
File "C:\dfp\dfp\get_orders.py", line 75
print 'Found an order with ID "{id}" and name "{name}".'.format(
^
SyntaxError: invalid syntax

Distribute as package on PyPI

This should make the project easier to configure and use.

Move settings into a dfp-prebid-setup.yml that looks something like:

orders:
  - bidder_code: somebidder
    advertiser_name: Some DFP Advertiser
    order_name: My HB Order
    targeting:
      placement_names:
        - Some Placement
        - Another Placement
      # Not yet implemented
      ad_unit_names:
       - An ad unit
      # Not yet implemented, but would allow empty targeting
      run_of_network: false
      ## Could later add additional DFP targeting options
    # Or a string preset: "auto" / "dense" 
    prebid_price_buckets:
      - min: 0
        max: 20.00
        precision: 2
        increment: 0.10
    # Optional
    prebid_send_all_bids: false
    number_of_creatives_per_line_item: 4
    currency_code: USD
user:
  email_address: [email protected]
  path_to_googleads_file: ./googleads.yaml
options:
  create_advertiser_if_does_not_exist: true
  use_existing_order: false

Use a CLI, dfpprebid, with commands:

  • create-config: generates a template dfp-prebid-setup.yml file
  • run [ordername] [options]: sets up the order and line items for the order specified, using the config file
    • Args: --config-file-path, --googleads-file-path, --create-advertiser, --use-existing-order

python -m tasks.add_new_prebid_partner gives error

Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, i
n _run_module_as_main
"main", mod_spec)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in
_run_code
exec(code, run_globals)
File "/Users/chris/Dev/DFP/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 350, in
main()
File "/Users/chris/Dev/DFP/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 346, in main
num_creatives,
File "/Users/chris/Dev/DFP/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 69, in setup_partner
hb_bidder_key_id = get_or_create_dfp_targeting_key('hb_bidder')
File "/Users/chris/Dev/DFP/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 150, in get_or_create_dfp_target
ing_key
key_id = dfp.create_custom_targeting.create_targeting_key(name)
TypeError: create_targeting_key() missing 1 required positional argument: 'display_name'

Multiple creatives for the same line-item

Hi and many thanks for this great tool! I was able to make it work even I don't know ANYTHING about Python :)

I've a suggestion though: would it be possible to add a parameter to specify the number of creatives to attach to each line-items?

For now I see only one creative per line-item, and in some occurrences the second ad doesn't serve any creative if the same partner wins with the same bid price on two different ad-slots.

Thanks
Eric

Creating line items permission denied

Hey guys, the script creates the order and the creatives but fails to create the line items, any idea what's happening here?

`Using existing advertiser with name "Prebid" and type "ADVERTISER".
Found an order with name "Test Order prebid automatic script 1.4".
Using existing order with name "Test Order prebid automatic script 1.4".
Created creative with name "appnexus: HB Test Order prebid automatic script 1.4, #1".
Traceback (most recent call last):
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/googleads/common.py", line 1382, in MakeSoapRequest
*packed_args, _soapheaders=soap_headers)['body']['rval']
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/zeep/proxy.py", line 42, in call
self._op_name, args, kwargs)
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/zeep/wsdl/bindings/soap.py", line 132, in send
return self.process_reply(client, operation_obj, response)
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/zeep/wsdl/bindings/soap.py", line 194, in process_reply
return self.process_error(doc, operation)
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/zeep/wsdl/bindings/soap.py", line 299, in process_error
detail=fault_node.find('detail'))
zeep.exceptions.Fault: [PermissionError.PERMISSION_DENIED @ ]

Traceback (most recent call last):
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/abdelhak.elmadkouri/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 355, in
main()
File "/home/abdelhak.elmadkouri/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 352, in main
setup_partner(user_email, advertiser_name, order_name, placements, ad_units, sizes, bidder_code, prices, num_creatives, currency_code)
File "/home/abdelhak.elmadkouri/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 80, in setup_partner
hb_bidder_key_id = get_or_create_dfp_targeting_key('hb_bidder')
File "/home/abdelhak.elmadkouri/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 161, in get_or_create_dfp_targeting_key
key_id = dfp.create_custom_targeting.create_targeting_key(name)
File "/home/abdelhak.elmadkouri/dfp-prebid-setup/dfp/create_custom_targeting.py", line 41, in create_targeting_key
keys = custom_targeting_service.createCustomTargetingKeys(keys)
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/googleads/common.py", line 1394, in MakeSoapRequest
e.detail, errors=error_list, message=e.message)
googleads.errors.GoogleAdsServerFault: [PermissionError.PERMISSION_DENIED @ ]
`

Support run-of-network line items (no targeted placements)

dfp.exceptions.BadSettingException: The setting "DFP_TARGETED_PLACEMENT_NAMES" must contain at least one DFP placement ID.

IMHO this should default to Run of network in the case of empty array not yield a error. On our case I see exactly no reason to have this targeted against specific placements, or adunits the reason is that one needs to generate many more than just having 1 per bidder which runs for all adunits.

Broken Pipe

Hi guys,

Any ideas about the below:

Creating line items...
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/pfarrow/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 355, in
main()
File "/home/pfarrow/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 352, in main
setup_partner(user_email, advertiser_name, order_name, placements, ad_units, sizes, bidder_code, prices, num_creatives, currency_code)
File "/home/pfarrow/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 92, in setup_partner
line_item_ids = dfp.create_line_items.create_line_items(line_items_config)
File "dfp/create_line_items.py", line 18, in create_line_items
line_items = line_item_service.createLineItems(line_items)
File "/usr/local/lib/python2.7/dist-packages/googleads/common.py", line 1384, in MakeSoapRequest
*packed_args, _soapheaders=soap_headers)['body']['rval']
File "/usr/local/lib/python2.7/dist-packages/zeep/proxy.py", line 42, in call
self._op_name, args, kwargs)
File "/usr/local/lib/python2.7/dist-packages/zeep/wsdl/bindings/soap.py", line 124, in send
options['address'], envelope, http_headers)
File "/usr/local/lib/python2.7/dist-packages/zeep/transports.py", line 95, in post_xml
return self.post(address, message, headers)
File "/usr/local/lib/python2.7/dist-packages/zeep/transports.py", line 67, in post
timeout=self.operation_timeout)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 555, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error("(32, 'EPIPE')",))

Thanks in advance!

How to set up for people who are not developers?

Hey,

I am trying to set up this on my windows PC , However I am having a lot of difficulties.

Can you please tell which softwares are required to run this program and how to run,

Please just a few steps to set me in right direction.

Best Regards

Get an error in create_line_items()

When I run:
python -m tasks.add_new_prebid_partner

I get the following error:

suds.WebFault: Server raised fault: '[CommonError.NOT_FOUND @ targeting.customTargeting.children[0].[keyId, valueId]; trigger:'11085365,447914416529']'

447914416529 value does not exist

Traceback (most recent call last):
<suds.sax.document.Document object at 0x7f6f0afd99e8>
  File "/code/languages/python/dfp-prebid-setup/env/lib/python3.6/site-packages/googleads/util.py", line 99, in PatchedHttpTransportSend
Server raised fault in response.
    fp = self.u2open(u2request)
  File "/code/languages/python/dfp-prebid-setup/env/lib/python3.6/site-packages/suds/transport/http.py", line 132, in u2open
    return url.open(u2request, timeout=tm)
  File "/usr/lib64/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/lib64/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/lib64/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib64/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: Internal Server Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/code/languages/python/dfp-prebid-setup/env/lib/python3.6/site-packages/suds/client.py", line 613, in send
    reply = self.options.transport.send(request)
  File "/code/languages/python/dfp-prebid-setup/env/lib/python3.6/site-packages/googleads/util.py", line 104, in PatchedHttpTransportSend
    raise suds.transport.TransportError(e.msg, e.code, e.fp)
suds.transport.TransportError: Internal Server Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/code/languages/python/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 375, in <module>
    main()
  File "/code/languages/python/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 370, in main
    currency_code,
  File "/code/languages/python/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 88, in setup_partner
    line_item_ids = dfp.create_line_items.create_line_items(line_items_config)
  File "/code/languages/python/dfp-prebid-setup/dfp/create_line_items.py", line 18, in create_line_items
    line_items = line_item_service.createLineItems(line_items)
  File "/code/languages/python/dfp-prebid-setup/env/lib/python3.6/site-packages/googleads/common.py", line 700, in MakeSoapRequest
    *[_PackForSuds(arg, self.suds_client.factory) for arg in args])
  File "/code/languages/python/dfp-prebid-setup/env/lib/python3.6/site-packages/suds/client.py", line 521, in __call__
    return client.invoke(args, kwargs)
  File "/code/languages/python/dfp-prebid-setup/env/lib/python3.6/site-packages/suds/client.py", line 581, in invoke
    result = self.send(soapenv)
  File "/code/languages/python/dfp-prebid-setup/env/lib/python3.6/site-packages/suds/client.py", line 619, in send
    description=tostr(e), original_soapenv=original_soapenv)
  File "/code/languages/python/dfp-prebid-setup/env/lib/python3.6/site-packages/suds/client.py", line 670, in process_reply
    raise WebFault(fault, replyroot)
suds.WebFault: Server raised fault: '[CommonError.NOT_FOUND @ targeting.customTargeting.children[0].[keyId, valueId]; trigger:'11085365,447914416529']'

Allow directly customizing the creative and line item configs

People often want to customize the creative and line item configuration. Rather than adding case-by-case customization, let's just expose the configuration for LineItem and Creative (and/or ThirdPartyCreative) to make it more flexible.

This could address the following feature requests:
SafeFrame: #83
Same advertiser exception / geotargeting: #59
Video ads: #61
Native ads: #57

This is straightforward for boolean fields but more complex for any items we need to create before associating them with the config, such as custom targeting keys.

It might be helpful if #50 is a prerequisite to this feature.

Script working fine on DFP SB but not on DFP premium

This script is working fine on DFP SB but not on DFP premium account. Any idea why?

Even >python -m dfp.get_orders dont give any output (DFP premium account already have more than 3K orders)

It always give the error: dfp.exceptions.DFPObjectNotFound: No DFP placement found with name prebid

Traffic video creatives for prebid for video

I think I'm missing something obvious.

My goal is to be able to traffic video creatives for prebid for video.

I've altered the config parameter in create_creatives.py to the following:

  config = {
    'name': name,
    'advertiserId': advertiser_id,
    'vastRedirectType': vast,
    'vastXmlUrl': vastXml,
  }

When I do this, I receive an error of:
KeyError: 'vastRedirectType'

This is the full error:

Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/lukeschoenberger/git/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 355, in <module>
    main()
  File "/Users/lukeschoenberger/git/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 352, in main
    setup_partner(user_email, advertiser_name, order_name, placements, ad_units, sizes, bidder_code, prices, num_creatives, currency_code)
  File "/Users/lukeschoenberger/git/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 77, in setup_partner
    creative_ids = dfp.create_creatives.create_creatives(creative_configs)
  File "dfp/create_creatives.py", line 25, in create_creatives
    creatives = creative_service.createCreatives(creatives)
  File "/usr/local/lib/python2.7/site-packages/googleads/common.py", line 1381, in MakeSoapRequest
    packed_args = self._PackArguments(method_name, args)
  File "/usr/local/lib/python2.7/site-packages/googleads/common.py", line 1239, in _PackArguments
    for ((_, param), param_data) in izip(op_params, args)]
  File "/usr/local/lib/python2.7/site-packages/googleads/common.py", line 1294, in _PackArgumentsHelper
    for item in data]
  File "/usr/local/lib/python2.7/site-packages/googleads/common.py", line 1284, in _PackArgumentsHelper
    elem_type, type_override is not None, data_formatted, set_type_attrs)
  File "/usr/local/lib/python2.7/site-packages/googleads/common.py", line 1351, in _CreateComplexTypeFromData
    for k, v in data if k != 'xsi_type'}
  File "/usr/local/lib/python2.7/site-packages/googleads/common.py", line 1351, in <dictcomp>
    for k, v in data if k != 'xsi_type'}
KeyError: 'vastRedirectType'

CustomTargetingError.KEY_NOT_FOUND @ name; trigger:'hb_bidder'

File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/var/www/html/vhosts/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 355, in
main()
File "/var/www/html/vhosts/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 352, in main
setup_partner(user_email, advertiser_name, order_name, placements, ad_units, sizes, bidder_code, prices, num_creatives, currency_code)
File "/var/www/html/vhosts/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 90, in setup_partner
HBPBValueGetter)
File "/var/www/html/vhosts/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 185, in create_line_item_configs
hb_bidder_value_id = HBBidderValueGetter.get_value_id(bidder_code)
File "/var/www/html/vhosts/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 146, in get_value_id
val_id = self._create_value_and_return_id(value_name)
File "/var/www/html/vhosts/dfp-prebid-setup/tasks/add_new_prebid_partner.py", line 133, in _create_value_and_return_id
self.key_id)
File "dfp/create_custom_targeting.py", line 77, in create_targeting_value
values_config)
File "/home/vagrant/.local/lib/python2.7/site-packages/googleads/common.py", line 1396, in MakeSoapRequest
e.detail, errors=error_list, message=e.message)
googleads.errors.GoogleAdsServerFault: [CustomTargetingError.KEY_NOT_FOUND @ name; trigger:'hb_bidder']### ###

In my case I use "smartadserver" -> http://prebid.org/dev-docs/bidders.html#smartyads

My config

# A string describing the order
DFP_ORDER_NAME = 'prebid_smartadserver_test_3'

# The email of the DFP user who will be the trafficker for
# the created order
DFP_USER_EMAIL_ADDRESS = '[email protected]'

# The exact name of the DFP advertiser for the created order
DFP_ADVERTISER_NAME = 'Smart'

# Names of placements the line items should target.
DFP_TARGETED_PLACEMENT_NAMES = ['hb_placements']

# Names of ad units the line items should target.
DFP_TARGETED_AD_UNIT_NAMES = []

#########################################################################
# PREBID SETTINGS
#########################################################################

PREBID_BIDDER_CODE = 'smartadserver'
HB_PRICE_BUCKET = 'hb_pb_smartadserver'
HB_BIDDERCODE = 'hb_adid_smartadserve'

Activate any previously-deleted DFP custom targeting values that we use on line items

When I run:

python -m tasks.add_new_prebid_partner

I get the following error:

suds.WebFault: Server raised fault: '[CustomTargetingError.DELETED_VALUE_CANNOT_BE_USED_FOR_TARGETING @ targeting.customTargeting.children[0].valueIds; trigger:'447854979471']'

Details:

I installed the script on the server and run it with settings :

PREBID_PRICE_BUCKETS = {
'precision': 2,
'min' : 0.01,
'max' : 20.00,
'increment': 0.01,
}

to generate 2000 line items in a single order and then I get the limitation error.
After that I deleted the key-values created by the script in the targeting part on UI Access, edited my settings.py and ran the script again . As a result the script showed a dfp exception ('[CustomTargetingError.DELETED_VALUE_CANNOT_BE_USED_FOR_TARGETING @ targeting.customTargeting.children[0].valueIds; trigger:'447854979471']').
Maybe the Id 447854979471 refers to a deleted value, but when I check Ids created on DFP I don't see any value with this ID.
Is there any suggestion to repair this issue?

What I think the problem is:

The script affects hb_pb KV values already created and deleted to lineitems, even if there are not part of the list of bids.
I think that the created IDs remain linked to the targeted values even if they are deleted.

Here is the entire error, starting from when i ran the command in terminal:

$python -m tasks.add_new_prebid_partner

Going to create 100 new line items.
     Order: AdlivePrebidscript35
     Advertiser: Adlive
     Owner: [email protected]

  Line items will have targeting:
     hb_pb = 0.01, 0.02, 0.03, ... 0.98, 0.99, 1.00
     hb_bidder = Appnexus
     placements = ['Adlive_prebid_palcement']

Is this correct? (y/n)
y
Found user with email "[email protected]" and name API service.
Found placement with ID "28545565" and name "Adlive_prebid_palcement".
Using existing advertiser with ID "4413663824", name "Adlive", and type "AD_NETWORK".
Created an order with id "2113121457"" and name "AdlivePrebidscript37".
Created creative with ID "138207478576" and name "Appnexus: HB AdlivePrebidscript37, #1".
Key "hb_bidder" exists and has 2 existing values.
Key "hb_pb" exists and has 500 existing values.

Created a custom targeting value with id "447855102108", name "0.02", and display name "0.02".
** ... ( Skip the creation of custom targeting values ) **
Created a custom targeting value with id "447855101658", name "0.98", and display name "0.98".
Creating line items...
<suds.sax.document.Document instance at 0x7f96a67f0830>
Server raised fault in response.
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/var/www/html/Blitz1/adlive/dfp-prebid-setup-master/tasks/add_new_prebid_partner.py", line 360, in
main()
File "/var/www/html/Blitz1/adlive/dfp-prebid-setup-master/tasks/add_new_prebid_partner.py", line 356, in main
currency_code,
File "/var/www/html/Blitz1/adlive/dfp-prebid-setup-master/tasks/add_new_prebid_partner.py", line 82, in setup_partner
line_item_ids = dfp.create_line_items.create_line_items(line_items_config)
File "dfp/create_line_items.py", line 18, in create_line_items
line_items = line_item_service.createLineItems(line_items)
File "/usr/local/lib/python2.7/dist-packages/googleads/common.py", line 700, in MakeSoapRequest
*[_PackForSuds(arg, self.suds_client.factory) for arg in args])
File "/usr/local/lib/python2.7/dist-packages/suds/client.py", line 521, in call
return client.invoke(args, kwargs)
File "/usr/local/lib/python2.7/dist-packages/suds/client.py", line 581, in invoke
result = self.send(soapenv)
File "/usr/local/lib/python2.7/dist-packages/suds/client.py", line 619, in send
description=tostr(e), original_soapenv=original_soapenv)
File "/usr/local/lib/python2.7/dist-packages/suds/client.py", line 670, in process_reply
raise WebFault(fault, replyroot)
suds.WebFault: Server raised fault: '[CustomTargetingError.DELETED_VALUE_CANNOT_BE_USED_FOR_TARGETING @ targeting.customTargeting.children[0].valueIds; trigger:'447854979471']'

Here is my settings.py:

 import os

ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
GOOGLEADS_YAML_FILE = os.path.join(ROOT_DIR, 'googleads.yaml')

DFP_ORDER_NAME = 'AdlivePrebidscript37'

DFP_USER_EMAIL_ADDRESS = '[email protected]'

DFP_ADVERTISER_NAME = 'Adlive'

DFP_TARGETED_PLACEMENT_NAMES = ['Adlive_prebid_palcement']

DFP_PLACEMENT_SIZES = [
  {
    'width': '300',
    'height': '250'
  },
   {
    'width': '728',
    'height': '90'
  },
   {
    'width': '160',
    'height': '600'
  }

]

DFP_CREATE_ADVERTISER_IF_DOES_NOT_EXIST = True

DFP_USE_EXISTING_ORDER_IF_EXISTS = False

DFP_CURRENCY_CODE = 'MAD'


PREBID_BIDDER_CODE = 'Appnexus'
    

PREBID_PRICE_BUCKETS = {
  'precision': 2, 
  'min' : 0.01,
  'max' : 1.00,
  'increment': 0.01,
}

try:
    from local_settings import *
except ImportError:
    pass

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.