Search code examples
jquerygoogle-analyticsvimeo

Uncaught SyntaxError: Failed to execute 'postMessage' on 'Window': Invalid target origin '' in a call to 'postMessage'


I have the following script:

 post : function (action, value, iframe) {
    var data = {
      method: action
    };

    if (value) {
      data.value = value;
    }

    // Source URL
    var iframeSrc = jQuery(iframe).attr('src').split('?')[0];

    iframe.contentWindow.postMessage(JSON.stringify(data), vimeoGAJS.getUrl(iframeSrc));
  },

I am using a third party plug-in to track vimeo videos on my website and I want to track video interaction as an event in Google Analytics. I am getting the following error message:

Uncaught SyntaxError: Failed to execute 'postMessage' on 'Window': Invalid target origin '' in a call to 'postMessage'.


Solution

  • This was fixed by removing the 'https:' from the src URL of the iframe....it should start '//player.vimeo.....'