Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Fetching Data on Click Events Using the Webkit PCM API #110

Open
Yuyan-Lei opened this issue Dec 4, 2023 · 1 comment
Open

Comments

@Yuyan-Lei
Copy link

Hi,

I am currently testing third-party measurement using the Webkit Private Click Measurement API and have set up a simulated environment on Glitch with a sample publisher site, advertiser site, and adTech site for this purpose. I have created an ad on the adTech site, which is displayed on the publisher site via an iframe. The demo can be accessed at https://c-3-publisher.glitch.me, and https://c-3-adtech.glitch.me.

One of my goals is to track the number of users who click on the ad but do not complete a conversion. To accomplish this, I need to record the click data whenever a user clicks on the ad. I have implemented a fetch request in the ad's onClick event handler to send this data to another server for recording. Below is the code for the example ad.

<div>
  <a
    id="ad"
    href="https://c-3-advertiser.glitch.me"
    attributionsourceid="2" 
    attributiondestination="https://c-3-advertiser.glitch.me"
    target="_top"
    onClick = () => {
      fetch(`[url]`, { method: "GET" })
      .catch((error) => {
        console.error("PCM fetch error: ", error);
      });
    }
  >
    <img
      src="[srcUrl]"
      width="100%"
    />
  </a>
</div>

I followed the example code provided in the Webkit repo (webkit: //github PCM: Allow measurement of links in nested, cross-site iframes ), using target="_top" in the iframe to ensure that when users click on an ad, they are redirected to the advertiser's page instead of loading it within the iframe. However, I've encountered an issue where the fetch request fails after successfully storing a click. This seems to occur because once the ad is clicked, the browser initiates a new page load, interrupting the execution of scripts on the current page, including any incomplete asynchronous fetch requests.

As a control experiment, I also tested with target="_blank", where a new tab opens to display the advertiser's site when the user clicks the ad. While the fetch operation succeeds in this scenario, the browser does not recognize it as a valid PCM click, and no "storing a click" log appears in the console.

Based on the testing above, I have two questions regarding this issue:

  1. Is there a workaround or solution to successfully execute the fetch request in this scenario?

  2. Is it necessary to use target="_top" in the iframe to ensure that the browser recognizes a user's click on the iframe as a successful PCM click?

Thank you for any insights or assistance you can provide!

@AramZS
Copy link

AramZS commented Dec 4, 2023

Hi all, @Yuyan-Lei is working with the team at The Washington Post on our overall testing of various privacy measures from a publisher perspective. This question comes out of some of our tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants