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).
Hello
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.
Hi
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?
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!
<div>{{message.id}}</div>
Anything I’d be missing there?
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!
Hey
Did you get this figured out? I believe that {{ email_message.id }} would dynamically pull in the campaign’s ID. Can you try that one and let me know how it goes? Also, when you tried {{ campaign_id }}, did that work?
Let me know if this works, and if I can help out with anything else.
-Byrne
Hi
{{ email_message.id }} seems to work well to pull the campaign id and flow message id. Thanks for that. None of the other values seemed to work.
Just curious, is there any variable that will pull the flow_id in?
Thanks for this answer,
-Mark
Log in to the Community
Use your Klaviyo credentials
Log in with Klaviyo
Use your Klaviyo credentials
Log in with KlaviyoEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.