Note: This codebase is no longer being actively worked on. The last time it was run at Curiosity Media was Sep 30, 2016. We encourage you to build off this example for your needs, but we do not plan on responding to issues in depth or adding new feature. But we wish you luck! 😀
This project was originally developed for internal use at Curiosity Media. Though much of the code is reusable, it is not plug-and-play. It likely require a developer to modify and execute these scripts to fit your particular set up.
Note that some conventions specific to our team at Curiosity Media. They're pointed out as best as possible.
Current scripts are oriented towards a Prebid setup. Previous examples exist in the v0.2 branch.
If you find any bugs, can suggest any improvements or find any part of the repository unclear, please report it in the issues.
Exposes methods for all the common tasks you need to generate line items. For ease of use, it converts all its functions into promises so that they can be easily chained.
Formats javascript objects used to create or update records in DFP. This code is imposes a lot of conventions used by our ads A/B testing framework at Curiosity Media, so it should be rewritten for your needs.
These are all the scripts we use at Curiosity Media to set up new line items when we onboard a new partner. They string together multiple calls to lib/dfp.js
and lib/formatter.js
for ease of use.
Follow our one-time setup.
The process for creating line items:
- Create an order.
- Create line items associated with that order.
- Create creatives for those line items.
- Create associations between those line items and those creatives.
For each of these steps, write a script that:
- Calculates all the combinations of parameters that you want to create.
- Calls
lib/formatter.js
to format a DFP-friendly javascript object for each of those combinations. - Calls the appropriate method on
lib/dfp.js
for those combinations.
lib/dfp.js
is completely reusable. Methods that create or update records in DFP expect to receive a fully formatted javascript object.
lib/formatter.js
is not reusable as it depends on the conventions of Curiosity Media's DFP setup, but you should be able to follow the model of this code to create your own.
To understand this code it can be helpful to understand the conventions of our A/B testing framework. For more information on the motivation for this framework, refer to this article on PubNation's blog.
When your DFP tasks take a long time, like creaing a large amoutn of line items, it's possible to run into problems where your node-google-dfp session expires. In this case it can be best to write a node script that creates a smaller number of line items and is executed multiple times by a bash script. The example scripts in scripts/
are built to avoid this problem. scripts/create-all-line-items.sh
is an example of how to call a node script multiple times in sequence to avoid this problem. Each call will instantiate a new session.