A page can send two valid CLS reports during one visit. Give both reports the same metric record and update its value before calculating a percentile. If a delivery retry arrives as well, the visit should still contribute one observation to the chart.
Trace one visit all the way to the chart
Start with a question your dashboard should answer. For a mobile product page, it might be “What CLS value covered three quarters of the measured visits?” Each visit with an eligible CLS observation gets one place in that distribution. A browser callback, a network request and a row in an analytics event stream each describe a different step along the way. Counting each of those rows as a visit gives extra weight to whichever visitors produced more callbacks or needed more delivery attempts.
Picture a shopper comparing two products in separate tabs. The first page shifts when a delivery estimate appears. The shopper switches tabs, returns to the first product and opens a section lower down. A later burst of unexpected movement changes that page's CLS. The two reports about the first product can both be accurate. Their shared identity is the evidence that lets the collector revise its observation. The second product has its own observation, even when both pages use the same template and run the same version of the storefront.
Follow a single test visit through the browser console, the collector and the reporting query. Write down which component assigns an identity, which part retries a failed delivery and which column the percentile calculation actually reads. This small trace often exposes a precise engineering task. An event stream can contain the correct IDs while a dashboard still calculates its percentile directly over every arrival.
Give a measurement and its updates different identities
The official web-vitals reporting documentation describes three fields worth preserving. The metric's id identifies the observation. Its value gives the value as currently measured. Its delta gives the difference since the previous report. The first callback carries the same number in both numeric fields. Choose the storage rule while all three still have their original meaning.
For a collector you control, a straightforward design stores snapshots. Build the record key from an explicit site identifier, the metric name and the library's metric ID. Add a revision number in your reporting code each time it receives another callback for that ID. Keep that revision on the payload throughout any retries. A second copy of revision two is the same event. Revision three describes new information and belongs in the same measurement record.
The revision number in this design belongs to your collector contract. Document who assigns it and when it increments. If a sender produces a new revision each time it attempts an upload, the receiver loses the easiest way to recognize an exact replay. Likewise, a timestamp attached by the server tells you when a packet arrived. A slow network can deliver an earlier snapshot after a later one. The most recently received packet can therefore describe the older state.
Test the merge with four packets
Use a tiny, invented fixture with a known answer. In the table, values are unitless CLS scores and the row order is the order of receipt. The identities have been shortened so someone reviewing the query can check the expected result by hand.
| Metric ID | Revision | Value | Expected action |
|---|---|---|---|
| A | 2 | 0.08 | Store the snapshot |
| A | 1 | 0.03 | Keep revision 2 |
| A | 2 | 0.08 | Ignore the replay |
| B | 1 | 0.04 | Create a second record |
After all four deliveries, the reporting input contains two CLS observations, 0.08 and 0.04. Record this expectation in a collector test. Run the same packets in a different order, then submit the complete set twice. Both trials should produce the same pair of values. A temporary connection failure between committing data and acknowledging a request is enough to make that second trial relevant.
Enforce the key in the data store. If two consumers handle copies of the same request in parallel, both can look up an empty record before either finishes writing. A unique key plus a conditional update, applied atomically, allows the later revision to win regardless of which worker finishes last. If two messages share a key and revision but carry different values, keep the conflict visible for investigation. Silently choosing the larger number hides a broken sender.
Choose a separate rule for an append-only system
Some analytics services accept events but cannot revise an old row. You can still store snapshots if the reporting query can select a single latest revision per metric ID. Choose that revision first, then group and calculate the percentile. If the query instead picks the latest event for the whole product template, thousands of distinct visits collapse into a single number.
Another option is to transmit deltas. In this model the receiver identifies each distinct update and sums its delta within one metric ID. In the example, the two unique updates for A would carry 0.03 and 0.05. Their sum yields the observed 0.08. Adding the two full snapshots would yield 0.11. Keep the chosen convention in the event schema so an analyst opening a column called “score” can tell which calculation it supports.
Deltas have a different failure mode. A missing early update leaves the sum incomplete even if a later update arrives. A later full snapshot can supply the latest measured value on its own. Check which guarantees the transport and analytics service can actually offer. If a delta is repeated and has no stable update identifier, equal numeric values alone cannot tell you whether it was replayed or whether two distinct changes happened to have the same size.
Keep real visit boundaries in the sample
Use the identity supplied with each measurement. Restoring a document from the back/forward cache can create a fresh metric ID for the returned visit. A rule that deduplicates by URL and browser session would merge those visits. Conversely, registering measurement callbacks again every time an already measured component mounts can create redundant observers. Initialize the measurement integration once at the intended document boundary, and inspect what actually happens on a return journey.
Run a few ordinary browsing sequences on the same test page. Open it, interact, switch to another tab, return, and leave. Try another visit that involves no qualifying interaction. INP can be absent for that visit. Store absence explicitly when computing coverage. Filling the gap with zero would create a measured response time for an interaction that never occurred. Zero can be a meaningful reported CLS value, so a blanket filter that discards all zero values would introduce a different bias.
When two testers use the same URL, their independent metric IDs should both survive the merge. Ask each tester to record the template, device category and build they used. Attach these dimensions consistently to the observation. A later retry might arrive after a deployment; stamping it with the current build at receipt can move the original visit into the wrong release cohort.
Build a dashboard you can reconcile
Keep three counts beside the percentile during rollout. Count incoming packets, distinct accepted revisions and distinct metric observations. In the four-packet fixture these counts are four, three and two respectively if the revisions are retained in an event log. The latest-value table has two rows. Label the counts with those meanings. Comparing them makes changes in callback frequency visible without interpreting every extra packet as another visitor.
First run the corrected aggregation over a fixed sample beside the existing dashboard. Compare the number of observations per metric and per template, then inspect a handful of IDs where the results differ. Record the query version and the date coverage changed. A jump on that day can reflect a measurement correction, and the historical chart needs enough context for a colleague to reconstruct the difference later.
Once the counts reconcile, investigate actual slow or unstable pages. For CLS, use the guide to finding and fixing layout shifts to connect a high observation to the visible component that moved. Keep the four-packet fixture with the reporting query. The next time an analytics migration changes the chart, anyone on the team can establish whether two measured visits still count as two.