Accessing segment in CMS template

  • 23 November 2020
  • 6 replies

Badge +2

Hi there,

Is there a way to e.g. access the segment of a visitor coming from an email in our CMS to personalise content?

Initially I had thought of e.g. adding segment data as url parameters to links in Klaviyo emails, which we can then use in the CMS. Is it possible to access segments as template tokens in email design so visitors to our site arrive at parameterised URLs?




Best answer by cassy.lee 30 November 2020, 23:16

View original

6 replies

Userlevel 5
Badge +10

Hi @Mailing, so just to ask some clarifying questions, were you able to get your segments created using the url parameters?

Also out of curiosity, what CMS are you utilizing on your site. It may be possible but any additional information that you could provide would be helpful in this instance. 

Badge +2

Hi @Paul S ,

I have no segments created yet, this is a theoretical question.

Our CMS is which has a segmentation module that allows query-parameter based content design


Userlevel 6
Badge +9

Hi @Mailing

Thanks for providing some additional context to your CMS. @Paul S and/or other Community members may have a different opinion on this, but if I understand your question correctly, you’re looking to track traffic from email in addition to what segment that user is in? 

If you are trying to track traffic from email, UTMs will work great for this purpose. You can create a UTM parameters for the emails that would only show up in If you are looking to transfer a specific segment to your CMS, you can export segment members as a CSV file. It’s worth noting that segments grow/shrink over time, so this may fluctuate.  

To configure your accounts UTM tracking, I recommend reviewing this UTM guide. Additionally, this guide on How to Segment by Acquisition source might also be helpful.


Badge +2

Hi @cassy.lee@Paul S thanks for your answers.


I am not hoping to “track traffic from email in addition to what segment that user is in”, I am hoping to access the user’s segment in our CMS as the user comes from an email. So:

  1. User in segment X gets email with link that has a url_parameter with user’s segment.
  2. Following that link takes user to e.g.
  3. CMS personalises content for `regulardonor` segment, higher engagement ensues.

As you say, importing segment members by CSV is one way to do this on some CMS’s, but our CMS doesn’t have user logins/cookies that recognise users by email. Unless you mean we can use the Klaviyo cookie somehow? (Your link on Segment Acquisition doesn’t seem so work, maybe that would explain it). In any case, segment export is laborious and would need to be repeated on segment update, whilst I’m hoping for a simple, dynamic solution.


url_params seem easiest to me as we could quickly create a segment, add the param, and make blocks on our site recognise url params.

I tried to do that in Klaviyo like this:

{% if 'UNYp28' in person|lookup:'$lists' %}

<p>Person in segment</p>

{% else %}

<p>Person not in segment</p>

{% endif %}

which is somewhat how we set things up in our preference center Hosted Page i.e. a contact’s lists are available to query in the template. (Related: I am having problem accessing simple custom properties in the template too

{{ person|lookup:'importSent' }}

 which might be the issue – I’m following this: ).


In sum, it’d be great to attach segment data to in-email urls to assist with personalisation. Is this possible?




Badge +2

To be clear, the code snippet I showed above indicates how I’d query a profile for a segment in a template, not how I‘d subsequently attach the url parameter. This is probably obvious, but...

Badge +2

Hi there. Anyone have any ideas on this?

@cassy.lee   @Paul S