Generate a UUIDv4
PHP does not have a native library for UUID generation, so these code examples are more extensive than what would likely be required if another programming language was used. PHP was chosen for this example because it is a widely supported server-side language.
When the following function is called, it generates a random UUID version-4:
<?php
function guidv4($data)
{
$data = $data ?? random_bytes(16);
$data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100
$data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}
?>
Write UUIDv4 value to a cookie
The following code makes a request to the function above to generate a UUID. It then sets the cookie flags decided upon by your organization. If a cookie has already been generated, then the expiration is extended.
<?php
if(!isset($_COOKIE['FPID'])) {
$cookie_value = guidv4(openssl_random_pseudo_bytes(16));
$arr_cookie_options = array (
'expires' => time() + 60*60*24*30*13,
'path' => '/',
'domain' => 'mysiteurl.com',
'secure' => true,
'httponly' => true,
'samesite' => 'lax'
);
setcookie($cookie_name, $cookie_value, $arr_cookie_options);
$_COOKIE[$cookie_name] = $cookie_value;
}
else {
$cookie_value = $_COOKIE[$cookie_name];
$arr_cookie_options = array (
'expires' => time() + 60*60*24*30*13,
'path' => '/',
'domain' => 'mysiteurl.com',
'secure' => true,
'httponly' => true,
'samesite' => 'lax'
);
setcookie($cookie_name, $cookie_value, $arr_cookie_options);
}
?>
Include the Cookie Value in the Identity Map
The final step is to use PHP to echo the cookie value to the Identity Map.
{
"identityMap": {
"FPID": [
{
"id": "<? echo $_COOKIE[$cookie_name] ?>",
"authenticatedState": "ambiguous",
"primary": true
}
]
}
}
FPID
.FPID
is a reserved identity namespace which is not visible in the interface lists of identity namespaces.Validate ECID generation
Validate the implementation by confirming that the same ECID is generated from your first-party device ID:
- Generate an FPID cookie.
- Send a request to Platform Edge Network using Platform Web SDK.
- A cookie with the format
AMCV_<IMSORGID@AdobeOrg>
is generated. This cookie contains the ECID. - Make a note the cookie value that is generated and then delete all cookies for your site except the
FPID
cookie. - Send another request to Platform Edge Network.
- Confirm the value in the
AMCV_<IMSORGID@AdobeOrg>
cookie is the sameECID
value as in theAMCV_
cookie that was deleted. If the cookie value is the same for a given FPID, the seeding process for the ECID was successful.
For more information about this feature, see the documentation.
Top Tips to Maximize Value with Adobe Experience Platform Data Distiller
Explore best practices for maximizing the value of Data Distiller, a powerful tool that transforms and enriches data in Adobe Experience...
Wed, Mar 19, 3:30 PM PDT (10:30 PM UTC)
B2B Reimagined: Transforming Go-to-Market Strategies for Profitable Growth
B2B brands are facing a digital revolution. Buyers expect hyper-relevant content and self-service, while internally AI is transforming...
Wed, Mar 19, 1:00 PM PDT (8:00 PM UTC)
Connect with Experience League at Summit!
Get front-row access to top sessions, hands-on activities, and networking—wherever you are!
Learn more