In order for the Intelligent Tracking Prevention (ITP) fix to work you need to install an endpoint on your server that the Symplify script can communicate with. This endpoint will read the cookies from the requests from the Symplify script and then re-set the cookies as first-party cookies. This will make them pass the ITP control.
The following example code is for nodejs.
// e.g. for a website blog.symplify.com eTld would be "com". So eTld+1 would be "symplify.com".
const eTLDPlusOne: string = "symplify.com";
/**
* DO NOT EDIT BELOW THIS LINE
**/
export const setITPCookies: (request: any, response: any) => void = (request, response) => {
let cookies = request.headers.cookie;
const responseHeaders: Record<string, any> = {
"Access-Control-Allow-Credentials": true,
"Access-Control-Allow-Origin": request.headers.origin ? request.headers.origin : "*"
};
if (!cookies) {
response.writeHead(200, responseHeaders);
response.end("No Cookies provided");
return;
}
const expireDate = new Date(Date.now() + 10 * 365 * 24 * 3600 * 1000).toUTCString();
cookies = cookies.split(";");
cookies.forEach(function(cookie: string) {
const cookieParts = cookie.trim().split("="),
name = cookieParts[0],
value = cookieParts[1];
if (name.search(/^(sg_)/) !== -1) {
responseHeaders["Set-Cookie"] = responseHeaders["Set-Cookie"] || [];
responseHeaders["Set-Cookie"].push(`${name}=${value};path=/;domain=.${eTLDPlusOne};expires=${expireDate};`);
}
});
response.writeHead(200, responseHeaders);
response.end("Cookie set");
}