How to communicate with Pixel SDK from iframe

You are here:
Estimated reading time: < 1 min

If you are using iframes on your website or have onsite campaigns running within iframe you can communicate with our main pixel as follows:

// sending an event
var ev = {"event": { "update": {"locality": "new_value"} }, "_vt":true};
window.parent.postMessage(JSON.stringify(ev), "*");

//setting a variable using setVar
var ev = {"setVar": ["var_name", "variable_value"], "_vt":true};

Our pixel automatically receives the data you send and processes it the usual way.

Note that you need to consider Same Origin Policy or Access-Control-Allow-Origin from iframe to parent window.

Was this article helpful?
Dislike 0
Views: 20