1st Party Cookie
Click Id information should be read from the adp_cid parameter on the request to the website.
Example affiliate url contains unique Click ID and offerId data:
https://yoursite.com/?adp_cid=7ede74f7-db12-4b99-b1ee-2c68247a5c64&adp_oid=555555Adpartners will automatically populate a new Click ID for each customer click with "adp_cid" parameter on query string.
Related offer id will be send at "adp_oid" on query string
The server-side cookie to be produced by the brand should have the following features
• This cookie should be refreshed for every request with Adpartners Click ID.
• Offer Id value should add to cookie value separated with "_" (Underscore) char.
• The cookie domain must be the same as the brand website domain.
• Cookie name must be "_adp".
• The secure attribute of the cookie must be set.
• The cookie period is 13 months. This time is compatible with other storage methods of this solution.
• If your tracking needs require cross-site accessing of the cookie, the SameSite attribute should be set to None.
• The httpOnly attribute should not be set. This ensures that the cookie can be read by JavaScript.
Use the following scripts to set apt cookie
$adp_cid = $_GET['adp_cid'] ?? null;
$adp_oid = $_GET['adp_oid'] ?? null;
if ($adp_cid) {
$adp_cookie_value = $adp_cid . "_" . $adp_oid;
$cookie_options = [
'expires' => time() + (13 * 30 * 24 * 60 * 60),
'path' => '/',
'domain' => '.yoursite.com', // change with brand top level domain
'secure' => false,
'httponly' => false
];
setcookie('_adp', $adp_cookie_value, $cookie_options);
}Please follow:
time() + (13 * 30 * 24 * 60 * 60): This represents the expiration time of the cookie. Thetime()function returns the current timestamp in seconds since the Unix Epoch. In this case, we add the duration of 13 months to the current time by multiplying the number of seconds in a month (30 * 24 * 60 * 60) and adding it to the current timestamp. This ensures that the cookie will expire 13 months from the current time.'/': This represents the path on the server where the cookie is available. In this case, it is set to'/', which means the cookie will be accessible across all paths on the server.'.yoursite.com': This represents the domain for which the cookie is valid. In the provided code, it is set to'.yoursite.com', but you should replace it with your brand's actual top-level domain. By setting the domain to'yoursite.com', the cookie will be accessible by any subdomain ofyoursite.com.false: This represents the "Secure" flag of the cookie. When set tofalse, it means the cookie can be transmitted over both secure (HTTPS) and non-secure (HTTP) connections. If set totrue, the cookie will only be transmitted over secure connections.false: This represents the "HttpOnly" flag of the cookie. When set tofalse, it means the cookie can be accessed by client-side scripts. If set totrue, the cookie will be inaccessible to client-side scripts, enhancing the security of the cookie against cross-site scripting (XSS) attacks.
These constant values define the behavior and characteristics of the cookie that will be set. You can modify them based on your specific requirements and security considerations.
Please note: This Java code assumes that the request and response objects are available in the current scope and that they are of types HttpServletRequest and HttpServletResponse, respectively. Additionally, you will need to import the javax.servlet.http.Cookie and javax.servlet.http.HttpServletRequest classes.
Please note: This VBScript code assumes that the Request and Response objects are available in the current scope and that they are of types ASP.Request and ASP.Response, respectively. Additionally, you may need to adjust the Domain property of the Response.Cookies("_adp") object to match your brand's top-level domain.
In PHP, we use the $_GET superglobal array to access query parameters. The isset() function checks if the "adp_cid" parameter is present, and the !empty() function ensures that it has at least one value.
The setcookie() function is used to set the "_adp" cookie. The parameters are as follows:
"_adp": The name of the cookie.$adp_cookie_value: The value of the cookie, concatenated from "adp_cid" and "adp_oid" query parameters.time() + (13 * 30 * 24 * 60 * 60): The expiration time of the cookie, set to 13 months from the current time.`'/': The path on the server where the cookie is available.
'.yoursite.com': The domain for which the cookie is valid. Change it to your brand's top-level domain.false: The "Secure" flag, which indicates if the cookie should only be sent over HTTPS.false: The "HttpOnly" flag, which prevents client-side scripts from accessing the cookie.
Please note that the provided code assumes the existence of the "adp_oid" query parameter as well. If it's not always present, you may need to add additional checks before accessing $_GET['adp_oid'][0] to avoid errors.
Descriptions:
getQueryParam(name): This is a JavaScript function that retrieves a querystring parameter. Here are the explanations for this function:getQueryParam(name): This function takes a specific parameter name (e.g., "adp_cid" or "adp_oid") and examines the page's querystring to find this parameter.var urlParams = new URLSearchParams(window.location.search);: This line creates a URLSearchParams object to work with the querystring of the current page.return urlParams.get(name);: This line retrieves and returns the value of the specified parameter using the parameter name. If the parameter is not found, it returnsnull.
createAdpCookie(): This JavaScript function is used to create an adpartners cookie. Here are the explanations for this function:var adpCid = getQueryParam("adp_cid");: In this line, the parameter "adp_cid" is retrieved from the querystring and stored in theadpCidvariable.if (adpCid !== null) { ... }: Thisifcondition checks whetheradpCidis null. IfadpCidis not null, the cookie creation process is executed.var adpOid = getQueryParam("adp_oid");: If the "adpCid" value is not null, this line retrieves the "adp_oid" parameter from the querystring and stores it in theadpOidvariable.var cookieValue = adpCid + "_" + adpOid;: The values of "adpCid" and "adpOid" are concatenated with an underscore character to form the value of the cookie.var expires = new Date(); expires.setMonth(expires.getMonth() + 13);: These lines set the cookie's duration to 13 months.var domain = window.location.hostname; ...: The domain for the cookie is extracted from the page's hostname and formatted accordingly.document.cookie = "_adp=" + cookieValue + "; expires=" + expires.toUTCString() + "; domain=" + domain + "; secure; SameSite=None";: In this line, a cookie named "_adp" is created with the specified properties (duration, domain, security, etc.).console.log("Adpartners Cookie created: " + cookieValue);: Finally, the value of the created cookie is logged to the console, providing information to the user.
Last updated