﻿#### 

There are 3 types of connections in **Sitecore CDP**:

1. ***Data System*** - can be used in Decision models as external source of data.
2. ***AI*** - can be used in Decision models as a logic block that performs any calculations on external service side.
3. ***Destination*** - can be used in Full stack experiences to send data to external services.

![Sitecore CDP - Destination connections](https://www.brimit.com/-/media/project/brimit/blog/2021/x3mxray/6/types_of_connections.jpg) 

In this article I`ll show how to create **Destination**connection to **Facebook Conversions API** and use it in triggered experiense to forward events to **Facebook Ads**.

#### How to create connection to Facebook Conversions API?

First of all, you need to have installed [Facebook Pixel](https://developers.facebook.com/docs/facebook-pixel) on your website. In your facebook account navigate to **Events Manager -&gt; Pixel app -&gt; Settings** and generate token for Conversions API:

![Sitecore CDP - Facebook Conversation API token](https://www.brimit.com/-/media/project/brimit/blog/2021/x3mxray/6/access_token.jpg)

The second key that you need is **Pixel ID**:

![Sitecore CDP - Facebook Ads Pixel ID](https://www.brimit.com/-/media/project/brimit/blog/2021/x3mxray/6/pixel_id.jpg)

Once you have **Pixel ID** and **token** it is time to test connection. In your facebook account navigate to **Events Manager -&gt; Pixel app -&gt; Test Events,** copy test event code *(TEST37153 in my case)* for future testing in Sitecore CDP and open **Graph API Explorer**:

![Sitecore CDP - Test Facebook Events](https://www.brimit.com/-/media/project/brimit/blog/2021/x3mxray/6/facebook_test_events_2.jpg) 

Insert your token in **Access Token** input and click submit button:

![Sitecore CDP - Facebook developer console](https://www.brimit.com/-/media/project/brimit/blog/2021/x3mxray/6/facebook_console_2.jpg) 

If you see response like on screenshot above, your connection is OK. If you return to **Test Events** tab you will see that your event is successfully tracked:

![Sitecore CDP - Facebook events tracking](https://www.brimit.com/-/media/project/brimit/blog/2021/x3mxray/6/facebook_test_success.jpg)

#### How to setup Facebook Conversions API connection in Sitecore CDP?

Login to your Sitecore CDP application account, **Connections -&gt; Add Connection-&gt; Destination**. Enter *Name* and *Description* of your connection,  choose *None* on Athentification tab and configure request parameters:

- **Method**: POST
- **URI**:  [https://graph.facebook.com/v12.0/{pixel\_id}/events?access\_token=](https://your_CH_endpoint/api/entities/query?query=Definition.Name=='M.PCM.Product'&amp;members=ProductName,ProductPrice){token}

Replace {pixel\_id} and {token} with your real values. To test your connection copy resuest body from recently tested facebook Graph API explorer:

![Sitecore CDP - Destination connection to Facebook](https://www.brimit.com/-/media/project/brimit/blog/2021/x3mxray/6/cdp_test.jpg)

If you testing request is successfull,  you will see recieved event in facebook **Test Events** tab. Save your connection with default mappings, don`t worry about testing Request body: it will be overwritten in triggered experience webhook in the future.

#### How to configure triggered experience?

In Sitecore CDP navigate to **Experiences -&gt; Full Stack -&gt; Create Experience -&gt; Triggered Experience**. In **Choose Connection** popup select your recently created Facebook destination connection:

![Sitecore CDP - Triggered Experience](https://www.brimit.com/-/media/project/brimit/blog/2021/x3mxray/6/triggered_experience.jpg)

For this demo I`ll show you how to forward *VIEW* event from your website to **Facebook Conversions API** *(for your real solution you can add more events as a trigger)*. Navigate to **Trigger** section and add custom trigger as shown on image below:

![Sitecore CDP - Add event trigger](https://www.brimit.com/-/media/project/brimit/blog/2021/x3mxray/6/view_trigger.jpg)

Go to **Webhook Composer** section and click on *Edit* button. Paste this Freemarker code into **API** tab:

```

<#assign pageUrl = "https://" + entity.pointOfSale + entity.arbitraryData.page>
<#assign timestamp = (.now?long / 1000)?floor?c>
<#assign guestUnique = guest.ref?replace("-","") + guest.ref?replace("-","")>
{
   "data": [
      {
         "event_name": "ViewContent",
         "event_time": ${timestamp},
         "event_source_url": "${pageUrl}",
         "action_source": "website",
         "user_data": {
            "em": "${guestUnique}",
            "client_user_agent": "Sitecore CDP"
         }
      }
   ],
   "test_event_code" : "TEST37153"
}

```

Parameters explanation:

- ```
    event_time - timestamp of triggered event in unix format (in seconds),
    ```
- ```
    user_data.em - any unique identifier of user in sha256 format. Unfortunatelly, I didn`t find how to caclulate sha256 in Freemarker, so for this demo example I just concatenate 2 times guest.ref value that is unique user identitier and looks like sha256; for real solution I store already sha256-hashed value of user email in extended guest profile properties.
    ```

Start your experience, navigate to your website and [generate some *VIEW* events](https://www.brimit.com/blog/cdp-1-how-to-connect-to-website). Go to **your experience -&gt; Operations -&gt; Execution Repost** where you will see statuses of youe triggered *VIEW* events. If all is OK you will see *SUCCESS* status:

![Sitecore CDP - Triggered Experience Execution Report](https://www.brimit.com/-/media/project/brimit/blog/2021/x3mxray/6/trigger_success.jpg?w=768&amp;hash=D32878CDA43FB2BBD1CFE1A076F563FB)

Because of we also passed **test\_event\_code** parameter, we can see that our events successfully hit facebook:

![Sitecore CDP - Success trigger](https://www.brimit.com/-/media/project/brimit/blog/2021/x3mxray/6/facebook_success.jpg)  

*NOTE: Remove **test\_event\_code** parameter for production events.*

In the next article I`ll show you how to setup **Facebook Ads** with triggered experience more flexible by using decision modeling. Stay updated!

Here goes the table of contents for my Sitecore CDP blog series:

- [Introduction](https://www.brimit.com/blog/cdp-0-intruduction)
- [How to connect Sitecore CDP to website](https://www.brimit.com/blog/cdp-1-how-to-connect-to-website)
- [Debugging tools](https://www.brimit.com/blog/cdp-2-debugging-tools)
- [How to pass extended data to Sitecore CDP](https://www.brimit.com/blog/cdp-3-how-to-pass-extended-data-to-sitecore-cdp)
- [How to use Data System connections (Decision model with Content Hub products)](https://www.brimit.com/blog/cdp-5-how-to-use-data-system-connections)
- [How to use AI connections (Web experience with Azure Cognitive Services)](https://www.brimit.com/blog/cdp-4-how-to-use-ai-connections)
- How to use Destination connections (Triggered experience webhook)
- How to use External service connections (Flows with External Service)
- Remarketing with Sitecore CDP and Facebook Ads

###### Author

[!\[sergey-200\](https://www.brimit.com/-/jssmedia/feature/blogs/authors/sergey-200.jpg?h=197&amp;iar=0&amp;w=200&amp;hash=0D636570F87F1C13C39E06EB19D9DF06)
Sergey Baranov
Sitecore MVP/ Senior Sitecore Developer](https://www.brimit.com/blog/author?authors=Sergey%20Baranov)

#### More on Sitecore

[!\[How Vercel Will Help You Save Effort When Deploying Sophisticated Sitecore Projects\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2024/vercel_cover-image.png)
#Guides#How-toDXPE-commerce
##### How Vercel Will Help You Save Effort When Deploying Sophisticated Sitecore Projects
Optimize and accelerate the development and deployment of complex multisite Sitecore projects.
Alexei Vershalovich on July 17, 2024](https://www.brimit.com/blog/how-vercel-will-help-you-save-effort-when-deploying-sophisticated-sitecore-projects)

[!\[Training Up Tomorrow's Sitecore MVPs: a Mentoring Success Story\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2023/sitecore-mentoring---cover-image.png)
#How-toDXP
##### Training Up Tomorrow's Sitecore MVPs: a Mentoring Success Story
How to participate in the Sitecore Mentor program and help younger colleagues jump-start a career in Sitecore development.
Sergey Baranov on October 2, 2023](https://www.brimit.com/blog/training-up-tomorrows-sitecore-mvps)

[!\[Going Headless. Part 2: When a Headless CMS Is Your Best Bet (if you have Sitecore)\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2022/headless/adobestock_456986731.jpg)
#How-toDXPE-commerce
##### Going Headless. Part 2: When a Headless CMS Is Your Best Bet (if you have Sitecore)
Discover how a headless CMS can benefit organizations that use Sitecore.
Daniil Raschupkin, Palina Trokhautsava on September 15, 2022](https://www.brimit.com/blog/going-headless-part-2-when-a-headless-cms-is-your-best-bet-if-you-have-sitecore)

![](https://bat.bing.net/action/0?ti=187017043&amp;tm=gtm002&amp;Ver=2&amp;mid=d73280a7-40d0-429e-96e9-f15518cf4733&amp;bo=2&amp;gtm_tag_source=1&amp;pi=0&amp;lg=en-US&amp;sw=800&amp;sh=600&amp;sc=24&amp;nwd=1&amp;tl=Dive%20into%20Sitecore%20CDP%20-%20How%20to%20use%20Destination%20connections%20(Triggered%20experience%20webhook)&amp;kw=sitecore%20CDP&amp;p=https%3A%2F%2Fwww.brimit.com%2Fblog%2Fcdp-6-how-to-use-destination-connections&amp;r=&amp;lt=298&amp;evt=pageLoad&amp;sv=2&amp;asc=D&amp;cdb=AQAY&amp;rn=554006)