# Use the contact\_id attribute?

**URL:** <https://community.brevo.com/t/use-the-contact-id-attribute/2251>\
**Category:** English\
**Created:** [Octobre 10, 2024, 8:40 UTC](https://community.brevo.com/t/use-the-contact-id-attribute/2251 "2024-10-10T08:40:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sal\_media](https://dub1.discourse-cdn.com/flex013/user_avatar/community.brevo.com/sal_media/32/827_2.png) [@sal\_media](https://community.brevo.com/u/sal_media)\
**Post date:** [Octobre 10, 2024, 8:40 UTC](https://community.brevo.com/t/use-the-contact-id-attribute/2251/1 "2024-10-10T08:40:58Z")

</div>

Hello 🙂

I would like to be able to use a unique contact ID to set up a light & custom referral program.

I have the impression that I cannot use the contact\_id attribute of brevo within an email template (to track a link, for example). Do you confirm this?

Thanks a lot,  
Chloe

---

<div class="post-metadata">

**Author:** ![Esther](https://avatars.discourse-cdn.com/v4/letter/e/8c91f0/32.png) [@Esther](https://community.brevo.com/u/Esther)\
**Post date:** [Octobre 10, 2024, 9:57 UTC](https://community.brevo.com/t/use-the-contact-id-attribute/2251/2 "2024-10-10T09:57:06Z")

</div>

Hey Chloe! 😊 You’re right—Brevo’s `contact_id` can’t be directly used within email templates for tracking links. However, there’s a workaround that might help you set up your referral program.

What you can do is use the Brevo API or create a custom field within your contact database. This way, instead of using `contact_id`, you can generate unique referral codes for each contact and insert those into your email templates. Here’s a simple breakdown of how you can approach it:

1. **Create a Custom Field** : Set up a new custom field (e.g., `referral_code`) for each contact in Brevo. This will store the unique code.

2. **Generate Unique Referral Codes** : Use a script or your CRM to generate unique referral codes and assign them to each contact in Brevo.

3. **Insert Referral Code in Emails** : Once you’ve assigned the referral codes, you can easily insert them into your email templates by using Brevo’s personalization feature (e.g., `{{ contact.custom.referral_code }}`).

This should allow you to track each contact’s referrals through a unique ID tied to their email link. If you need more help with setting it up, let me know, and I can walk you through the details!

---

<div class="post-metadata">

**Author:** ![sal\_media](https://dub1.discourse-cdn.com/flex013/user_avatar/community.brevo.com/sal_media/32/827_2.png) [@sal\_media](https://community.brevo.com/u/sal_media)\
**Post date:** [Octobre 10, 2024, 10:36 UTC](https://community.brevo.com/t/use-the-contact-id-attribute/2251/3 "2024-10-10T10:36:50Z")

</div>

Hi Esther,

THANKS ! You confirm what I understood; I therefore switch to my “plan B”, which is exactly the option you describe.

For step 2, what is the «&nbsp;cleanest&nbsp;» solution to generate this unique number? Can a Brevo function help me? Or do you recommend a third-party tool (which one?)

You mention «&nbsp;a script&nbsp;» ; do you think I can find a model somewhere ?

Many thanks,  
Chloe

---

<div class="post-metadata">

**Author:** ![Esther](https://avatars.discourse-cdn.com/v4/letter/e/8c91f0/32.png) [@Esther](https://community.brevo.com/u/Esther)\
**Post date:** [Octobre 10, 2024, 1:22 UTC](https://community.brevo.com/t/use-the-contact-id-attribute/2251/4 "2024-10-10T13:22:27Z")

</div>

Hi Chloe! I’m glad the workaround seems like a good fit for you! 😊

For generating unique referral codes, here are a couple of options:

1. **Using Brevo’s Built-in Features** : While Brevo doesn’t have a direct feature to generate unique codes, you can use its automation and personalization features to assign unique identifiers. If you have a spreadsheet of contacts, you could generate codes in Excel (using functions like `RAND()` or `RANDBETWEEN()`) and then upload them to Brevo as custom fields.

2. **Third-Party Tools** : If you’re looking for a more automated solution, you might want to check out tools like **Zapier** or **Integromat** (now called Make). They can help you create unique codes and automate the process of adding them to your Brevo contacts. For instance, you could set up a Zap that generates a unique code every time a new contact is added.

Let me know if it works or if you need help implementing this 😊
