Pass page view id and a client identifier to ads, analytics, etc.
We need a general variable available to amp-pixel, analytics, ads, that is "unique" (Just Math.random should be fine) per page view. So, just a random number we create once per page.
This is a change in https://github.com/ampproject/amphtml/blob/master/src/url-replacements.js
Some ads require access to a CID. Create configuration per ad network for the fallbackCookieName. Will need to figure out how to get consent in this case.
CC @rudygalfi @kashyapnitin @avimehta
Is this intended to function only as a cachebuster? Math.random() isn't nearly high enough entropy, in our experience, to function as unique pageview ID (across hundreds of billions of pageviews)
how about
Unique is a bit of a complicated concept :)
Anyway, good feedback.
How much entropy do you need? Are 64bit enough or do you need 128bit?
64bit should be enough for ultra-likely-unique-per-week :)
Actually, shouldn't Math.random be completely sufficient? Its only needs to be unique per client identifier.
@cramforce you are right. Client id + page id are probably going to be enough uniqueness.
On Thu, Nov 19, 2015 at 1:40 PM, Malte Ubl [email protected] wrote:
Actually, shouldn't Math.random be completely sufficient? Its only needs to be unique per client identifier.
— Reply to this email directly or view it on GitHub https://github.com/ampproject/amphtml/issues/969#issuecomment-158206068.
Being unique in combination with client ID is fine for our applications, this should just make sure to specify that this is not unique on its own.
Just as a quick note for those who care, you start getting collisions in the low billions of items with 64 bits of entropy (https://en.wikipedia.org/wiki/Birthday_problem): P(collision exists amongst n items getting getting hashed into d buckets) ~= 1 - exp(-n^2/2d) So, for instance, if n = 8 billion (2^33) and d = 2^64, you have the probability of collision at: 1 - exp(- (2^33)^2 / (2*(2^64)) = 1 - exp(- (2^66) / (2^65)) ~= 86%
Cool. Will make sure to document.
[Renamed issue to reflect that this applies to cases other than just ads.]
@cramforce What's the status/timing of completing this?
#977 is out for review, but hasn't gotten any review love while I was on vacation :)
Page view id landed.
Exposing the client identifier is next.
Fixed by #1146