Skip to main content
Question

Campaign and Flow Message ID Template Variable

  • February 13, 2025
  • 6 replies
  • 40 views

Forum|alt.badge.img+2
  • Problem Solver I
  • 13 replies

Is there any way to identify a campaign or flow message within the message itself through the use of some template variable? Our app provides personalized recommendations within an email and it would be very helpful for external tracking to be able to pass this id to our system and to GA4 (I recognize I can add it to the utm params but that doesn’t help me to track our product recommendations and personalizations within the email on open).

Did this topic or the replies in the thread help you find an answer to your question?

6 replies

MANSIR2094
Problem Solver IV
Forum|alt.badge.img+15
  • Problem Solver IV
  • 227 replies
  • February 13, 2025

Hello ​@obviyo , 

You can use Klaviyo's event.extra data or message.id as a unique identifier within your email template. To track personalized recommendations effectively, consider embedding a custom variable within your recommendation links, such as:

?rec_id={{ event.extra.rec_id }}

For GA4 tracking, you might pass the ID as a custom event parameter using Klaviyo’s Webhooks or API to log interactions. If implementation gets complex, feel free to reach out for guidance.

 


Forum|alt.badge.img+2
  • Author
  • Problem Solver I
  • 13 replies
  • February 13, 2025

Hi ​@MANSIR2094 ,

I tried to use {{ message.id }} in email but it doesn’t ever seem to print out anything. Is there a certain condition that needs to be met before that works or does that only work in certain types of emails?


MANSIR2094
Problem Solver IV
Forum|alt.badge.img+15
  • Problem Solver IV
  • 227 replies
  • February 13, 2025

@obviyo {{ message.id }} is only available in flow emails, not campaigns. If you're using it in a campaign, it won't populate. For campaigns, you can try {{ campaign.id }} instead.

 

If you need a consistent identifier across both, consider passing a custom variable via event data for flows or using UTM parameters for campaigns. Let me know if you need help setting this up!

 


Forum|alt.badge.img+2
  • Author
  • Problem Solver I
  • 13 replies
  • February 13, 2025

@MANSIR2094 Hmm, I tried {{ message.id }} in a flow email and it didn’t print out anything for me. I just threw it into the source of a text block like so:

<div>{{message.id}}</div>

Anything I’d be missing there?


MANSIR2094
Problem Solver IV
Forum|alt.badge.img+15
  • Problem Solver IV
  • 227 replies
  • February 13, 2025

@obviyo ,Klaviyo doesn’t render Liquid variables inside raw HTML elements like <div>. Instead, try placing {{ message.id }} in a standard text block without HTML.

 

If you must use it in HTML, wrap it in a Klaviyo variable tag:

{% capture message_id %}{{ message.id }}{% endcapture %}<div>{{ message_id }}</div>

 

Let me know if you need further troubleshooting!

 


Adunni
Active Contributor II
Forum|alt.badge.img+1
  • Active Contributor II
  • 21 replies
  • February 14, 2025

Hi ​@obviyo ,

Yes! You can absolutely track campaign or flow messages within the email itself using Klaviyo’s template variables. Here’s how you can do it:

Solution: Use Klaviyo’s Built-in Variables

  1. Flow & Campaign Identifiers

    • Use {{ flow.id }} to track a flow email.
    • Use {{ campaign.id }} to track a campaign email.
    • If you need the flow name, use {{ flow.name }}.
  2. Pass Data to Your System & GA4

    • Append these variables to your tracking links like this:
       

      arduino

      CopyEdit

      https://yourtrackingurl.com?flow_id={{ flow.id }}&campaign_id={{ campaign.id }}

    • This ensures your personalized recommendations are linked back to specific emails.
  3. Custom Profile Properties for Deep Tracking

    • You can store flow/campaign data in profile properties and sync them with your system.
    • Example: Set a profile property like last_email_flow: {{ flow.name }} for later reference.

Next Steps

If you need help integrating this into your tracking system or GA4 setup, I’d be happy to guide you! Just let me know, and let’s optimize your email tracking together. 🚀

Cheers,
Adunni