Custom Key Value Pairs were set after PubGuru header bidding script. Here’s how to fix it

If you want to send custom Key-Value Pairs to DFP, all you need to do is set up some javascript on your pages. This needs to be set before the MonetizeMore’s PubGuru header bidding script is loaded.

The following script tag can be expanded to include more custom key-value pairs, using the same format.

<script>

window.m2hb = window.m2hb || {};

window.m2hb.kvps = window.m2hb.kvps || {};

window.m2hb.kvps[“customKVP”] = “value”;

</script>

Note that: if you want to add more key-values in the future, you should not redefine window.m2hb.kvps object.

Instead, you should add more values with bracket- or dot-notation to add new values:

<script>

window.m2hb = window.m2hb || {};

window.m2hb.kvps = window.m2hb.kvps || {};

window.m2hb.kvps[“customKVP”] = “value”;

window.m2hb.kvps[“anotherValue”] = “secondValue”;

</script>

— also valid (dot-notation) —

<script>

window.m2hb = window.m2hb || {};

window.m2hb.kvps = window.m2hb.kvps || {};

window.m2hb.kvps.customKVP = “value”;

window.m2hb.kvps.anotherValue = “secondValue”;

</script>

While this setup will allow you to add key-value pairs in multiple script tags, as long as they are above the MonetizeMore’s PubGuru header bidding script in the HTML, it is strongly recommended that you keep them together (for ease of editing). Also note that the last option (dot-notation), has some limitations, as you can’t start keys with a number. The square bracket style is recommended.

Key with Multiple Values

To create a key with multiple values, the value field in the code should be a javascript array, for example:

<script>

window.m2hb = window.m2hb || {};

window.m2hb.kvps = window.m2hb.kvps || {};

window.m2hb.kvps[“multiKey”] = [“value1”, “value2”, “value3”];

</script>

Back to Notification Center