Automatically setup and update your Line Items on GAM for Smart Holistic+
When setting up Smart Holistic+, your ad ops team would have to create hundreds of line items in GAM.
This tool automates setup for GAM.
You will need credentials to access your GAM account programmatically. This summarizes steps from DFP docs and the GAM PHP library auth guide.
- If you haven't yet, sign up for a GAM account.
- 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.
- Enable API access to DFP
- Sign into your DFP 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 "Trafficker".
- Click Save.
- Clone this repository.
- Include the library via Composer: `$ composer require googleads/googleads-php-lib
- Rename key
- Rename the Google credentials key you previously downloaded (
[something].json
) togoogleServiceAccount.json
and move it to the project root folder
- Rename the Google credentials key you previously downloaded (
- Make a copy of adsapi_php.ini and save it into the project root folder.
- In
adsapi_php.ini
, set the required fields:application_name
is the name of the application you used to get your Google developer credentialsnetwork_code
is your GAM network number; e.g., forhttps://www.google.com/dfp/12398712#delivery
, the network code is12398712
.jsonKeyFilePath
is the path to your JSON key filescopes
is "https://www.googleapis.com/auth/dfp"impersonatedEmail
is the email account of the user you want to impersonate as, if any (something like [email protected])
Let's try it out! From the top level directory, run
php script/connexionTest.php
and you should whether the connexion is OK or not
Modify the following settings in script/smartGamSetup.php
- Currency is the AdServer Currency (USD, EUR...)
- NetworkId according to your networkId
Then, from the root of the repository, run:
php script/smartGamSetup.php
You should be all set! Review your order, line items, and creatives to make sure they are correct. Then, approve the order in GAM.