# Install LinkedIn CAPI with JENTIS

LinkedIn campaign tracking allows businesses to monitor the effectiveness of their marketing efforts on the platform. By utilizing unique campaign parameters, businesses can accurately attribute conversions and engagements to specific LinkedIn campaigns. Detailed analytics provided through LinkedIn campaign tracking empower businesses to optimize their strategies and maximize their return on investment.

## Official Ressources <a href="#installlinkedincapiwithjentis-officialressources" id="installlinkedincapiwithjentis-officialressources"></a>

* <https://learn.microsoft.com/en-us/linkedin/>
* <https://learn.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?tabs=HTTPS1>
* <https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads-reporting/conversions-api?view=li-lms-2023-09&tabs=http>
* <https://www.linkedin.com/help/lms/answer/a1711116>

## Installation Methods <a href="#installlinkedincapiwithjentis-installationmethods" id="installlinkedincapiwithjentis-installationmethods"></a>

There are two methods available to install the LinkedIn CAPI in JENTIS: the Direct API Token Method (recommended) and the OAUTH 2.0 Method. The Direct API Token Method will automatically override the OAUTH 2.0 configuration in JENTIS, as it is the preferred method to use.

### Direct API Token - Step by Step - Guide <a href="#installlinkedincapiwithjentis-directapitoken-stepbystep-guide" id="installlinkedincapiwithjentis-directapitoken-stepbystep-guide"></a>

#### **Create a new Direct API Token**

Please follow the instructions and guidelines from the official LinkedIn documentation to set up a Direct API Token: [LinkedIn Direct API Token Setup](https://www.linkedin.com/help/lms/answer/a1711116)

#### **Insert Direct API Token in Tool Edit View**

Insert the generated Direct API Token in the LinkedIn Tool Edit View under the field **Direct API Token**.

<figure><img src="https://2315305008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy15ncufYr341K5U8q6Of%2Fuploads%2FLwU3shPBFxpiAoTvY112%2Fimage.png?alt=media&#x26;token=3f0a0604-0e97-48c7-8186-b9cacf46bc4f" alt=""><figcaption></figcaption></figure>

After saving, it will work!

### OAUTH 2.0 - Step by Step - Guide <a href="#installlinkedincapiwithjentis-oauth2.0-stepbystep-guide" id="installlinkedincapiwithjentis-oauth2.0-stepbystep-guide"></a>

#### **Create a new app in LinkedIn**

Follow the steps given below to implement the 3-legged OAuth for LinkedIn APIs:

* A LinkedIn Developer application to [create a new application](https://www.linkedin.com/developer/apps/new?csrfToken=ajax%3A8674117952230020505) or [select your existing application](https://www.linkedin.com/developers/apps)

#### **Configure your Application**

Official Documentation: <https://learn.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?context=linkedin%2Fcontext&tabs=HTTPS1#step-1-configure-your-application>

#### **Request an Authorization Code**

Official Documentation: <https://learn.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?context=linkedin%2Fcontext&tabs=HTTPS1#step-2-request-an-authorization-code>

<figure><img src="https://2315305008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy15ncufYr341K5U8q6Of%2Fuploads%2F4nbQ9XELh6HiUgB3HpID%2Fimage.png?alt=media&#x26;token=c8da57f9-8978-47d3-a4e0-0a023190aa3e" alt=""><figcaption></figcaption></figure>

To request the Authorization Code, please redirect to your main domain, for example. The sole purpose of this action is to extract the authorization code from the redirected URL.

This is the example request for retrieving the authorization code with the necessary scopes for JENTIS. Please replace

* Client-ID
* Redirect-URL

with your configured values from the APP:

{% code overflow="wrap" lineNumbers="true" %}

```
https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id={Client-ID}&redirect_uri={Redirect-URL}&state=foobar&scope=rw_conversions%20r_ads
```

{% endcode %}

{% hint style="warning" %}
The `{Redirect-URL}` must be replaced with the urlencoded version of the given redirect-URL.

Use f.e. <https://www.urlencoder.org/> to encode your redirect-URL.
{% endhint %}

On the resulted redirect-URL the URL-Parameter **code** is added. Please copy/paste this authorization code.

Example goal-url after successful authentication:

{% code overflow="wrap" lineNumbers="true" %}

```
https://www.jentis.com/?code=AQSmy0q_HjWVRuN13pyE4i646Hfvpg6fFxNqQvOrSZLUSobxkkeJWCCIvEvOF2T3ZwWMSWhM-elssFrgfm-1LyYSmdfyvw2-1IShau_KFMHccex7iObqsFIf7Nvt9p3K8r7ymY6Yqq7rJLGmtQ9jvUb66qGw8QD3B8nYDCeQ4q_tobdmnr1Ha75EUcxEXpJbGaTPDB7UWeAyBxgV5dI&state=foobar
```

{% endcode %}

### **Install the LinkedIn Tool in JENTIS**

<figure><img src="https://2315305008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy15ncufYr341K5U8q6Of%2Fuploads%2FTJWVEq7JVaeZHGdIjqWM%2Fimage.png?alt=media&#x26;token=ba734708-e370-4746-9ff3-05bcd7ce242f" alt=""><figcaption></figcaption></figure>

Transfer now all the necessary tool-constants to the configuration page of the LinkedIn tool in JENTIS:

{% hint style="warning" %}
The `{Client-Secret}` must be replaced with the urlencoded version of the given redirect-URL.

Use f.e. <https://www.urlencoder.org/> to encode your client\_secret.
{% endhint %}

<table data-header-hidden><thead><tr><th width="179.69140625"></th><th></th></tr></thead><tbody><tr><td><strong>Client-ID</strong></td><td><p>Generated in the Application Credentials Auth Screen</p><p>(See Screenshot from LinkedIn above)</p></td></tr><tr><td><strong>Client-Secret</strong></td><td><p>Generated in the Application Credentials Auth Screen</p><p>(See Screenshot from LinkedIn above)</p><p></p><p>The <code>{Client-Secret}</code> must be replaced with the urlencoded version of the given redirect-URL.</p><p>Use f.e. <a href="https://www.urlencoder.org/">https://www.urlencoder.org/</a> to encode your client_secret.</p></td></tr><tr><td><strong>Redirect-URL</strong></td><td><p>Configured in the Application Credentials Auth Screen and must be used 1:1 the same on the JENTIS Configuration</p><p>(See Screenshot from LinkedIn above)</p></td></tr><tr><td><strong>APP-Code</strong></td><td>Added on the redirect_uri after the customer successfully created an APP-Code (described above how to retrieve it)</td></tr></tbody></table>

### Default Tags <a href="#installlinkedincapiwithjentis-defaulttags" id="installlinkedincapiwithjentis-defaulttags"></a>

We default to installing a Campaign-Parameter Detection Tag and a Conversion-Tag for the server-side approach.

#### Campaign-Detection - Tag <a href="#installlinkedincapiwithjentis-campaign-detection-tag" id="installlinkedincapiwithjentis-campaign-detection-tag"></a>

The Campaign-Parameter Detection Tag is searching on all pageviews for the URL-Parameter “li\_fat\_id” and stores it in the server-side storage of the tool. This value must be then re-used on the conversion tag.

#### Conversion - Tag <a href="#installlinkedincapiwithjentis-conversion-tag" id="installlinkedincapiwithjentis-conversion-tag"></a>

Official Documentation: <https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads-reporting/conversions-api?view=li-lms-2023-09&tabs=http#streaming-conversion-events>

Everything mentioned in the official documentation can be configured on our side. By default, we have already set up everything needed to track conversions to LinkedIn, including the campaign parameter. If you wish to track additional information, please follow the guidelines provided by LinkedIn and refer to the official documentation.

### Where can I find the conversion ID?

In the LinkedIn Campaign-Manager click on the conversion you want to track.

<figure><img src="https://2315305008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy15ncufYr341K5U8q6Of%2Fuploads%2FlwMpjXlDW7JvshDrVq5R%2Fimage.png?alt=media&#x26;token=400b9339-6500-4b95-9239-69ddcf7ac124" alt=""><figcaption></figcaption></figure>

On the following page, please extract from the URL the conversion-id and enter this in the corresponding placeholder on the conversion-template in JENTIS.

<figure><img src="https://2315305008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy15ncufYr341K5U8q6Of%2Fuploads%2FIMdQIr94M3BKya90MvMZ%2Fimage.png?alt=media&#x26;token=ca3e30be-c566-44d8-9dba-d7997c4dded8" alt=""><figcaption></figcaption></figure>

## First Tests <a href="#installlinkedincapiwithjentis-firsttests" id="installlinkedincapiwithjentis-firsttests"></a>

After generating an APP-Code, please trigger a conversion within the next 5 minutes via preview to retrieve and store an access token. Failure to do so promptly after generating the APP-Code may result in its expiration, rendering it unusable. In the event of changing the APP-Code at the Tool-Edit-Level, our system will automatically attempt to obtain a new Authorization Token. Upon successful testing, JENTIS manages the authorization and refresh tokens for future use.

{% hint style="warning" %}
When an APP-Code has been used once, it is not usable for a second attempt. You must generate a new APP-Code until you have retrieved your first access token.
{% endhint %}

## Deduplication <a href="#installlinkedincapiwithjentis-deduplication" id="installlinkedincapiwithjentis-deduplication"></a>

By default, if you are using both client-side and server-side tags, deduplication is active and shared between them, provided that the corresponding tags (client-side conversion and server-side conversion) use the same trigger.
