CDN-Driven Storage
You can use your CDN to store envelopes instead of relying on less-secure client-side storage.
We support using Cloudflare Workers to store the RampID envelope in an HTTP cookie instead of client-side. As some browsers differentiate between client-side (Javascript) and server-side (HTTP) storage for data expiration, leveraging a single approach to store data may help simplify some of your workflows and create more durable identifiers.
Cloudflare Serverless Application
Prerequisites
Node.js
An enterprise Cloudflare account.
Setup
First, git clone
Then, run npm install in the ats-cloudflare-serverless directory.
Environment variables
The serverless framework configuration for Cloudflare requires the following parameters:
- Account ID (
CLOUDFLARE_ACCOUNT_ID) - can be retrieved from Cloudflare dashboard overview page - Zone ID (
CLOUDFLARE_ZONE_ID) - can be retrieved from Cloudflare dashboard overview page - Domain (
CLOUDFLARE_DOMAIN) - path for domain site where function will be deployed( e.g example-site.com) - Set Path (
CLOUDFLARE_SET_PATH) - route to trigger the function to set an HTTP cookie - Retrieve Path (
CLOUDFLARE_RETRIEVE_PATH) - route to trigger the function to retrieve an HTTP cookie - Auth Key (
CLOUDFLARE_AUTH_KEY) - can be retrieved from Cloudflare dashboard. Go to My Profile -> Scroll down to API Keys -> API Key. - Auth email (
CLOUDFLARE_AUTH_EMAIL) - logging email
$ CLOUDFLARE_ACCOUNT_ID=999 \ CLOUDFLARE_ZONE_ID=999 \ CLOUDFLARE_DOMAIN=domain.com \ CLOUDFLARE_SET_PATH=set_cookie \ CLOUDFLARE_RETRIEVE_PATH=retrieve_cookie \ CLOUDFLARE_AUTH_KEY=999 \ [email protected] \ npm run deploy
$ CLOUDFLARE_ACCOUNT_ID=999 \
CLOUDFLARE_ZONE_ID=999 \
CLOUDFLARE_DOMAIN=domain.com \
CLOUDFLARE_SET_PATH=set_cookie \
CLOUDFLARE_RETRIEVE_PATH=retrieve_cookie \
CLOUDFLARE_AUTH_KEY=999 \
[email protected] \
npm run removeats.js Cloudflare Configuration
Once you have spun up your CDN "backend" in Cloudflare, you will need to configure the client-side version of ats.js to make use of the Workers. There are several configuration parameters to pay attention to:
useCloudFlare: a boolean to indicate whether or not the Cloudflare backend should be used. If true, populate the parameters below.
setCookiePathCloudFlare: The absolute path to set envelopes as HTTP cookies as defined by the CLOUDFLARE_SET_PATH serverless variable.
retrieveCookiePathCloudFlare: The absolute path to read envelopes from HTTP cookies as defined by the CLOUDFLARE_RETRIEVE_PATH serverless variable. This will be used in ats.retrieveEnvelope calls.
cookieAgeCloudFlare: Cookie lifespan in milliseconds. We recommend 2592000000 (30 days) to match envelope expiration.
{
"logging":"debug",
"placementID":9999,
"email":"[email protected]",
"useCloudFlare": true,
"setCookiePathCloudFlare": 'https://liveramp.com/set_cookie',
"retrieveCookiePathCloudFlare": 'https://liveramp.com/retrieve_cookie',
"cookieAgeCloudFlare": 2592000000
}Other CDNs
Not using Cloudflare? We're working on it! Drop us a line at [email protected] with information on your preferred CDN and implementation.
Updated 2 days ago