Giter Club home page Giter Club logo

example-dfp-line-item-generator's Introduction

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! 😀

Example DFP Line Item Generator

State of this project

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.

Issues and questions

If you find any bugs, can suggest any improvements or find any part of the repository unclear, please report it in the issues.

Code explanantion

node_modules/node-google-dfp-wrapper

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.

lib/formatter.js

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.

scripts/*.js

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.

Getting started

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.

Curiosity Media's A/B testing conventions

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.

Scripting large batches

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.

example-dfp-line-item-generator's People

Contributors

juancaicedo avatar nanek 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

Watchers

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

example-dfp-line-item-generator's Issues

Error: soap:Server: [PublisherQueryLanguageSyntaxError.UNPARSABLE @ Unable to parse query: 'Where '

Copied from nanek/node-google-dfp-wrapper#24 by @brianibok

Hi All,

Getting the error below when I try to run the script to generate the line-items:

node scripts/create-line-items.js --order ORDER_NAME --start 1 --end 1

Error:
Progress [=-] 50% 0.0screating line items failed
because Error: soap:Server: [PublisherQueryLanguageSyntaxError.UNPARSABLE @ Unable to parse query: 'Where '
Syntax error at line 0, column 0.]

However no modifications were made to the script

createLineItems error

When I call createLineItems with the object below, I get a soap error. I tried using the code directly from the createCampaign example, but ran into errors straight away with attributes of LineItem that don't exist. I went through the wsdl docs and changed up the LineItem, but still... Any help you could give sure would be appreciated...

[
  {
      "orderId": 428533037,
      "name": "Tester",
      "externalId": 55,
      "startDateTime": {
        "date": {
          "year": 2016,
          "month": 3,
          "day": 16
        },
        "hour": 19,
        "minute": 0,
        "second": 0,
        "timeZoneID": "America/Chicago"
      },
      "endDateTime": {
        "date": {
          "year": 2016,
          "month": 3,
          "day": 30
        },
        "hour": 19,
        "minute": 0,
        "second": 0,
        "timeZoneID": "America/Chicago"
      },
      "creativeRotationType": "WEIGHT",
      "lineItemType": "STANDARD",
      "allowOverbook": true,
      "skipInventoryCheck": true,
      "primaryGoal": {
        "goalType": "LIFETIME",
        "unitType": "IMPRESSIONS",
        "units": 122
      },
      "targeting": {
        "inventoryTargeting": {
          "targetedPlacementIds": 3441557
        }
      },
      "costType": "CPM",
      "creativePlaceholders": [
        {
          "size": {
            "width": 728,
            "height": 90,
            "isAspectRatio": false
          }
        }
      ],
      "costPerUnit": {
        "currencyCode": "USD",
        "microAmount": 2000000
      }
    }
]

ERROR:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Client</faultcode>
      <faultstring>Unmarshalling Error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'costType'. One of '{"https://www.google.com/apis/ads/publisher/v201602":creativeTargetings}' is expected. </faultstring>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

Set up problems

Please let us know here if you're having troubles getting started!

CreateOrder not able to send externalOrderId

My createOrders call works flawlessly whenever I pass my object without the externalOrderId, like:

var args = { orders: [{
    name: 'My Order Name',
    advertiserId: 86999999,
    traffickerId: dfpTraffickerID
}]};

However, I get a soap error when I pass the externalOrderId, like:

var args = { orders: [{
    name: 'My Order Name',
    advertiserId: 86999999,
    traffickerId: dfpTraffickerID,
    externalOrderId: '#100043'
}]};

The error is below and I sure would appreciate any help you could give. I've tried using v201505, v201511 and v201602.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Client</faultcode>
      <faultstring>Unmarshalling Error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'externalOrderId'. One of '{"https://www.google.com/apis/ads/publisher/v201602":secondaryTraffickerIds, "https://www.google.com/apis/ads/publisher/v201602":salespersonId, "https://www.google.com/apis/ads/publisher/v201602":secondarySalespersonIds, "https://www.google.com/apis/ads/publisher/v201602":totalImpressionsDelivered, "https://www.google.com/apis/ads/publisher/v201602":totalClicksDelivered, "https://www.google.com/apis/ads/publisher/v201602":totalViewableImpressionsDelivered, "https://www.google.com/apis/ads/publisher/v201602":totalBudget, "https://www.google.com/apis/ads/publisher/v201602":appliedLabels, "https://www.google.com/apis/ads/publisher/v201602":effectiveAppliedLabels, "https://www.google.com/apis/ads/publisher/v201602":lastModifiedByApp, "https://www.google.com/apis/ads/publisher/v201602":isProgrammatic, "https://www.google.com/apis/ads/publisher/v201602":programmaticSettings, "https://www.google.com/apis/ads/publisher/v201602":appliedTeamIds, "https://www.google.com/apis/ads/publisher/v201602":lastModifiedDateTime, "https://www.google.com/apis/ads/publisher/v201602":customFieldValues}' is expected. </faultstring>    
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

Also, what would be the best way to log the soap requests as they're sent? I'd like to get a look at them going out to figure out what's going wrong...

Thanks a ton man,
Ferg

`argv.offset` undefined

Hi all,
I was able to set up my order correctly, but when I tried setting up my line items I couldn't get any value for argv.offset. If you notice, this is the undefined part of the order name. Also, how are you able to associate the line items with the order? I'm working off the granular-prebid branch

screen shot 2016-02-13 at 11 07 47 pm

Got error when run npm install

When I try to use this code, use npm install to install dependency npm package, it always report this error.
Can you help to point out where I am wrong?

Tested under NodeJS 4.2.4

lz 2016-01-04 at 5 20 54 pm

Use prebid as default?

@nanek @mmilleruva @CarsonBanov

Based on the discussion in #1 and #29, and previous discussions we've had, does it make more sense for prebid to be the default branch? If you think most publishers are looking to generate line items for prebid, as opposed to for individual header bidders, we could do this. The prebid branch is also simpler (and the code is better thanks to @nanek).

Error: getTokens Error

Hi All,

Trying to create an order using the script and everything works fine up until I run the create order command and get the error below:

getTokens Error invalid_grant
.../example-dfp-line-item-generator/node_modules/node-google-dfp/lib/DfpUser.js:69
throw error;
^

Any ideas?

Better report error messages

Errors from the API are not properly thrown back to the application code. They come in as strings in the body of the response like <soap-fault>Error!</soap-fault>.

Maybe the best way of handling this would be for lib/user when it executes a function from a service, to check the resulting string for an error and if it finds one, to construct a javascript error and throw it.

WSDL Error: undefined: undefined

I've gotten this fairly cryptic error when running scripts that hit the DFP API ~400+ times

creating line items failed Error: undefined: undefined
    at WSDL.xmlToObject (/Users/admin/line-item-generator/node_modules/node-google-dfp/node_modules/soap/lib/wsdl.js:1400:19)

After some digging, I uncovered this error message and figured out that it's because the generator makes multiple requests for custom criteria values when preparing line items (each of which is done individually and happens quickly).

I found a good solution to be to rely on the caching mechanism more. The function first looks up the value in the local store. If it doesn't find it, then it queries DFP for all the values that match the keyid passed in. It then stores all of those in the local store and looks up the initial value again.

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.