Skip to content

Instantly share code, notes, and snippets.

@davidwasamrf
Last active November 24, 2016 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidwasamrf/7505f74d5c87e2310437fa32c2741e90 to your computer and use it in GitHub Desktop.
Save davidwasamrf/7505f74d5c87e2310437fa32c2741e90 to your computer and use it in GitHub Desktop.

Use cases

  • miss behaving ad network : blacklist in emergency
  • overcome server side issue : Override configuration
  • replacing an adNetwork with another
  • on the fly revenue optimization testing : order, append, prepend

JSON solution

Blacklist a set of ad networks

{
  "adNetworks": {
    "blacklist": ["adx", "sovrn"]
  }
}

Reorder ad networks

{
  "adNetworks": {
    "order": ["adx", "sovrn", "facebook"]
  }
}

Add an ad network first in the list

{
  "adNetworks": {
    "prepend": [
      {
        "name": "facebook",
        "accountId": "1715891948661649",
        "adTags": {
          "300x250": "1715892455328265"
        }
      }
    ]
  }
}

Add an ad network last in the list

{
  "adNetworks": {
    "append" : [
      {
        "name": "facebook",
        "accountId": "1715891948661649",
        "adTags": {
          "300x250": "1715892455328265"
        }
      }
    ]
  }
}

Replace an ad network with another

{
  "adNetworks": {
    "replace" : {
      "adNetwork": "adx",
      "with" : [
        {
          "name": "facebook",
          "accountId": "1715891948661649",
          "adTags": {
            "300x250": "1715892455328265"
          }
        }
      ]
    }
  }
}

Override ad networks

{
  "adNetworks": [
    {
      "name": "facebook",
      "accountId": "1715891948661649",
      "adTags": {
        "300x250": "1715892455328265"
    },
    {
      "name": "adx"
    }
  ]
}
OR
{
  "adNetworks": {
    "override" : [
      {
        "name": "facebook",
        "accountId": "1715891948661649",
        "adTags": {
          "300x250": "1715892455328265"
      },
      {
        "name": "adx"
      }
    ]
  }
}

Javascript solution

Use javascript in order to manipulate server side twister configuration using Nashorn.

  TwisterFactory.getCurrentConfig()
    .andRemove("adx", "facebook")
    .andPrepend("facebook", [1658462294414926, "300x250", 1658465174414638])
    .andReplace("sovrn")
      .with("facebook", [1658462294414926, "300x250", 1658465174414638])
    .orderBy("adx", "sovrn", "facebook")
    .build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment