Skip to main content

Overview

The retailer-visitor-id is a unique, persistent identifier for a visitor on your site. It must be stable across sessions on the same device and browser, and it must be set as a cookie with a maximum age of at least 30 days (up to 13 months). This page shows how to generate and persist a retailer-visitor-id in JavaScript. The 13-month maximum aligns with Safari’s Intelligent Tracking Prevention (ITP) cap on first-party cookies set via JavaScript.
For native mobile apps, use the platform-provided advertising ID instead of a cookie-based approach:

JavaScript Implementation

The snippet below generates a UUID v4, stores it in a first-party cookie on first visit, and returns the existing value on subsequent visits.

How It Works


Key Requirements

  • Minimum lifetime: 30 days. Longer lifetimes (up to 13 months, the ITP cap) improve attribution accuracy.
  • Not a session cookie: Always set Max-Age or Expires. A session cookie that clears on browser close is not acceptable.
  • Consistency: The same value must be passed in the retailer-visitor-id parameter on every ad request for that visitor.

What’s Next