Enabling Click IDs
Warning
Deprecation Notice
The Marketing Version 202310 (Marketing October 2023) and earlier versions (excluding 202306 and 202307) have been sunset. Additionally, the unversioned APIs will be sunset soon. We recommend that you migrate to the versioned APIs as well as migrate to the new Content and Community Management APIs to avoid disruptions. See the Migration page for more details.
If you haven’t yet migrated and have questions, submit a request on the LinkedIn Developer Support Portal.
Capturing Clicks IDs, such as li_fat_id
(LinkedIn First-Party Ad Tracking ID) from ad landing page URLs is critical to power the Conversions API for improved match rates by including it as a user identifier when streaming conversion events to LinkedIn.
Prerequisites
To activate click IDs as a first party cookie tracking, you need to Access LinkedIn Insight Tag in Campaign Manager and enable Enhanced conversion tracking. This automatically appends a click ID parameter li_fat_id
to the landing page URLs every time a user clicks on a LinkedIn ad and is redirected to advertiser's landing page.
This is enabled by default for all new Insight Tags that are recently created. For more information, see Insight Tag Troubleshooting guide.
Alternatively, developers can also use Find Insight Tag by Ad Account API to retrieve Insight Tag, and then use Partial Update Insight Tag API and set firstPartyTrackingEnabled
to true
.
Capturing Click IDs
You can capture Click ID li_fat_id
by parsing from the Click URLs and/or read from Cookies (if Insight Tag code is added on website) as outlined in the following two approaches:
Parsing li_fat_id
From Click URL
Once Enhanced conversion tracking is enabled from the created Insight Tag (but not required to actually install Insight Tag code on advertiser's website), you can implement a Javascript code on the website to retrieve Click IDs from the landing page URLs by parsing li_fat_id
from the URL as shown in an example below and pass it as a hidden field during form submission for conversion. View-though conversion attribution may be limited in this approach.
// New browsers. Not supported on IE <= 11 and Opera Mini.
const li_fat_id = (new URLSearchParams(window.location.search)).get("li_fat_id");
// Old browsers
function getParam(param) {
const queryParams = window.location.split("?")[1];
const queryKeyValues = queryParams.split("&");
for (const keyValue of queryKeyValues) {
const [key, value] = keyValue.split("=");
if (key === param) {
return value;
}
}
return "";
}
// usage
getParam('li_fat_id');
Reading li_fat_id
From Cookies
Once enhanced conversion tracking is enabled from the created Insight Tag and Insight tag has been installed on your website, you can also implement additional Javascript code on advertiser website to retrieve Click IDs by reading li_fat_id
cookie from the cookie store as shown in an example below. You can then pass it as a hidden field during form submission for conversion. The cookie will persist for 30 days from the most recent ad click that redirected to the landing page where Insight Tag has been installed. View-though conversion attribution are supported in this approach if user previously clicked on one of your ads in the last 30 days and was redirected to the landing page where Insight Tag has been installed.
function getCookie(name) {
let matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([.$?*|{}()[\]\\/+^])/g, '\\$1') + "=([^;]*)"
));
// usually a cookie value is encoded, so decode it.
return matches ? decodeURIComponent(matches[1]) : undefined;
}
// usage
getCookie('li_fat_id');
Using Click IDs as User Match Identifier for Conversions
Once you have retrieved li_fat_id
from click URLs and/or cookies, you can include them when Streaming conversion events through API as LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID
, which is one of the supported user match identifier idType to improve your match rates with LinkedIn.