- Proxy the JavaScript SDK so the library loads from your domain instead of
cdn.hightouch-events.com. See Proxying the JavaScript SDK. - Proxy events so the SDK sends collected events to your domain instead of
hightouch-events.com. See Proxying events. - Issue first-party, HTTP-only cookies from a service on your domain so anonymous and user identifiers persist past Safari’s cookie limits. See Intelligent Tracking Prevention.
Proxying
To use first-party tracking, set up a proxy so clients send their event data to your domain rather than directly to Hightouch.Before you begin
You’ll need a certificate for whatever domain you plan to use for the proxy. This guide uses Amazon Cloudfront, but any CDN or reverse proxy will work.Proxying the JavaScript SDK
Out of the box, the JavaScript SDK is served from cdn.hightouch-events.com. But you can serve the JavaScript SDK from your own domain instead. First, create a Cloudfront distribution with the following settings:
Then, point your clients to the CNAME you configured. If using the JavaScript snippet, you can do this by replacing
cdn.hightouch-events.com in the body of the snippet with your CNAME.
Proxying events
By default, events are sent tohightouch-events.com. But you can configure Hightouch to send events to your own domain instead.
First, create a Cloudfront distribution with the following settings:
Then, set your SDK’s
apiHost setting to the CNAME you configured. For example, if you are using the Browser SDK:
Intelligent Tracking Prevention
Intelligent Tracking Prevention (ITP) is an automatic feature of the Safari web browser, designed to limit user tracking. More specifically, the program is designed to prevent analytics libraries from using client-side Javascript to correlate user sessions. ITP configures the Safari browser in the following ways:- Third-party cookies are blocked by default.
- First-party cookies (and localStorage) have a default expiry of 7 days.
- A user revisiting a website will restart the 7 day expiry.
- Storing an identifier in a Cookie.
- Storing an identifier in localStorage.
Mitigating ITP
When properly configured, Hightouch Events can store session identifiers outside of ITP’s 7 day expiry. It does this by using first party, HTTPOnly cookies. These are not subject to Safari’s 7 day expiry. These types of cookies are generally used for logging into a website and are less likely to be limited, even when dealing with anonymous users. These “server cookies” must follow several rules put in place by ITP:- The server providing the HTTPOnly cookie must be on the same domain as the website.
- If the server is on a subdomain of the website, its IP address must match the IP address that served the main HTML document.
Client SDK setup
Once your HTTPCookieService is reachable on your domain, you may configure your Hightouch Events SDK to make use of it when generating Cookies:Server setup
The Events SDK expects to interact with a customer’s HTTPCookieService that implements a specific spec for two routes. You can name the endpoints whatever you want, as long as you configure the client SDK to call those endpoints.An API for creating server and browser cookies
This route should look for the following browser cookies (from Events SDK):request.headers.get("Cookie")["htjs_anonymous_id"]request.headers.get("Cookie")["htjs_user_id"]
response.cookie("htjs_anonymous_id_srvr", anonVal, {httpOnly:true, ...})response.cookie("htjs_user_id_srvr", userIdVal, {httpOnly:true, ...})
anonVal = request.headers.get("Cookie")["htjs_anonymous_id_srvr"]userIdVal = request.headers.get("Cookie")["htjs_user_id_srvr"]response.cookie("htjs_anonymous_id", anonVal, ...)response.cookie("htjs_user_id", userIdVal, ...)
An API for clearing server cookies
This route should look for server cookies and clean them:res.cookie("htjs_anonymous_id_srvr", "", {maxAge: 0, httpOnly:true, ...});res.cookie("htjs_user_id_srvr", "", {maxAge: 0, httpOnly:true, ...});
API spec
The spec of the actualrequest and response payloads are kept intentionally vague. The spec should fit a variety of server environments.
The Events SDK only requires that the server: A) handles cookies and B) returns a 200 status code.