WICG / floc

This proposal has been replaced by the Topics API.
https://github.com/patcg-individual-drafts/topics
Other
936 stars 90 forks source link

interestCohort on third party sites #116

Closed nikoplusx closed 3 years ago

nikoplusx commented 3 years ago

Reading the docs here and here. As well the docs for how to be part of the origin trials here I

  1. Registered my domain on the origin trials - let's say https://example.io - yes it is https
  2. I used the following snippet to retrieve the interest cohort on a few pages

    function addTrialToken(tokenContents) {
      const tokenElement = document.createElement('meta');
      tokenElement.httpEquiv = 'origin-trial';
      tokenElement.content = tokenContents;
      document.head.appendChild(tokenElement);
    }
    
    if(isChrome){
          addTrialToken('<token I received from the origin trials>');
    
          document.interestCohort().then((cohortInfo) => {
            const events = [];
            events.push({ cohortId: cohortInfo.id, cohortVersion: cohortInfo.version });
          });
     }

My problem is that I cannot get the interestCohort method to work and I am always getting a Uncaught TypeError: document.interestCohort is not a function. What am I doing wrong here?

If my registered domain is https://example.io, I am trying to access the cohort from https://example.io/other.html

michaelkleber commented 3 years ago

The origin trial is only running right now for a fraction of people in Chrome Beta. If you want to start up your own copy of Chrome with the API available, there are instructions at https://developer.chrome.com/blog/floc/#enable-floc-with-browser-flags.