Skip to content

Instantly share code, notes, and snippets.

@recyclerobot
Created August 31, 2015 23:58
Show Gist options
  • Save recyclerobot/f056953f3e0749b2a942 to your computer and use it in GitHub Desktop.
Save recyclerobot/f056953f3e0749b2a942 to your computer and use it in GitHub Desktop.
// Forward all postMessage calls from the iframes that have data in the form {method:, arguments:} directly to Segment.
window.onmessage = function(e){
var method = e.data.method;
var args = e.data.arguments ? _.values(e.data.arguments) : null;
if (analytics[method]) {
analytics[method].apply(analytics, args);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment