# Track URL activity in RCS messages

Rich communication services (RCS) messages often contain links to help end users go to the correct location or perform the required action. You can track these URLs to see how end users interact with your messages and identify their preferences and behavior.

You can then use this information to do the following:

- **Personalization**: Personalize future messages, making them more relevant.
- **Performance analytics**: Analyze the effectiveness of your campaigns.

This tutorial shows how to track URL clicks in RCS and generate reports. Customize the example to meet your use case and requirements.

## Products and channels [#products-channels]

- [RCS](https://www.infobip.com/docs/rcs)
- [Broadcast](https://www.infobip.com/docs/broadcast)

## Prerequisites [#prerequisites]

- **Infobip account**: If you do not have one, [create a free trial account](https://www.infobip.com/docs/essentials/getting-started/create-an-account) and select **RCS** as the channel on the welcome screen.
- **Infobip API key** with ```rcs:message:send``` scope: For information about creating an API key with the required scope, refer to [API authorization](https://www.infobip.com/docs/essentials/api-essentials/api-authorization).
- **HTTP client**: This tutorial uses curl. Alternatively, you can choose the official [Infobip SDK](https://www.infobip.com/docs/sdk) for the required programming language.
- **RCS agent or sender**: If you want to configure a custom RCS sender, please contact your Infobip account manager.
- **Destination**: A phone number to which RCS messages are sent. If the RCS agent is not launched, you can only send to safelisted phone numbers.

## Implementation over the Infobip web interface [#implementation-over-web-interface]

### Create and launch a new broadcast [#create-launch-broadcast]

1. On the [Infobip web interface](https://portal.infobip.com/login), go to **Moments** > **Broadcasts**.
2. Select [**Create new broadcast**](https://www.infobip.com/docs/broadcast/create#new-broadcast).
3. Select **RCS** as the channel.
4. Choose the **Recipients** and select a **Sender**.
5. In the **Content** section, create a **Text** message that includes a URL.

    Example: *For news about CPaaS in Infobip, go to https:<span>//</span>www<span>.</span>infobip.com/news/infobip-is-one-of-the-top-cpaas-providers-in-metrigys-cpaas-metrirank-report.*

6. Select **Tracking and reporting** and do the following:
    - Select **Shorten URLs**.
    - (Optional) Remove https:// from the domain.
    - Choose a domain - **Default** or **Custom**.
    - Select **Track URL clicks** so that performance reports are available in [Analyze](https://www.infobip.com/docs/analyze/reports#performance-report).

7. Select **Continue to preview**.
8. Verify the content in the preview page.
9. Select **Launch**.

### Get performance reports in Analyze [#get-performance-reports-analyze]

After you launch the campaign, you can get the Performance DLR from the Analyze section.

1. On the Infobip web interface, go to **Analyze** > **Reports**.
2. Select **Create reports**.
3. Select **Performance**.
4. In the **Performance report content** section, select **Detailed clicks by URL and recipients**.
5. Select the other metrics that you want for the report. Example: Date range and status.
6. Select **View additional filters**.
7. In the **Communications** field, select the name of the broadcast that you created.
8. Select **Create report**.
9. When the report is created, download it to see the results.

## Implementation over API [#implementation-over-api]

1. [Create an API request](https://www.infobip.com/docs/api/channels/rcs/send-rcs-messages) to send RCS messages. In the API request, enable **webhooks** and **tracking**.

    ```curl showLineNumbers copy filename="curl"
    curl -X POST https://api.infobip.com/rcs/2/messages \
    -H 'Authorization: App {YOUR_API_KEY}' \
    -H 'Content-Type: application/json' \
    -d '{
    "messages": [
        {
        "sender": "{YOUR_SENDER}",
        "destinations": [
            {
            "to": "{YOUR_DESTINATION}"
            }
        ],
        "content": {
            "text": "Shorten URL and tracking test https://www.infobip.com/news/infobip-is-one-of-the-top-cpaas-providers-in-metrigys-cpaas-metrirank-report",
            "suggestions": [],
            "type": "TEXT"
        },
        "webhooks": {
            "delivery": {
            "url": "YOUR_URL",
            "notify": true
            },
            "callbackData": "URLtracking test",
            "seen": {
            "url": "YOUR_URL"
            }
        }
        }
    ],
    "options": {
        "tracking": {
        "shortenUrl": true,
        "trackClicks": true,
        "trackingUrl": "YOUR_URL"
        }
    }
    }
    ```

2. After a successful request (200 OK), you should receive the RCS message on the destination.
3. Select the link in the RCS message. Delivery reporting (DLR) is now included in the webhook URL.

## Additional resources [#additional-resources]

- [RCS API reference](https://www.infobip.com/docs/api/channels/rcs/send-rcs-messages)
- [RCS](https://www.infobip.com/docs/rcs)
- [Response status and error codes](https://www.infobip.com/docs/essentials/api-essentials/response-status-and-error-codes)
- [Infobip Broadcast](https://portal.infobip.com/broadcast)
- [Infobip SDKs](https://www.infobip.com/docs/sdk)