How to assign dynamic Profile Property value at sign up

  • 4 March 2024
  • 6 replies

Badge +1


I’m looking for a way to assign a unique code to a user at sign up which they can pass on to friends as a unique referral code. It feels like a dynamically generated Profile Property value would work here, but I’m completely new here, so not sure if I can’t find how to do that or if it’s not a thing in Klaviyo.

Toying with the idea of using a 0.01 value voucher code but can’t work out how to, or if I can, store that code against a specific user (so we can link referred users, who enter that code at sign up, to the original referring user if you see what I mean)

Is there a way I could achieve this use case?


Best answer by StefanUE 4 March 2024, 16:04

View original

6 replies

Userlevel 5
Badge +18

Hey @pop_lou , great question, super interesting!

I’m not sure if it would be possible to assign a unique code to a user at signup, other than using a dynamic discount code which is unique to each recipient. From there, you could instruct the person to share the unique code with their friends as a way of referring them, however you’d have no real control over who actually ends up using the code, just that they are unique and are attached to a particular profile.

THIS ARTICLE will have more information on creating and managing dynamic unique discount codes.

Of course, an alternative to this would be to use a loyalty/referral app which would make the whole process very much doable and straightforward, however with a platform cost associated.

I’m happy to chat further!

Userlevel 4
Badge +19

Hi @pop_lou,

Appreciate you writing in. I agree with what @StefanUE mentioned above. I also wanted to share an in-house approach that could solve for this use case and might be of interest.

Note, this method is technical and requires developing a custom referral-related event(s) and managing the coupon generation internally. The benefit here is that you could create your own in-house referral program, which could be more cost-effective in the long run.


  1. Whenever a customer places a first-time order, a custom event (e.g. “Eligible for Referral”) would trigger.
  2. This event would trigger a separate “Refer a Friend” flow, and the event payload (i.e. the properties included with the event) would include a top-level property for the referral coupon (e.g. “referral_code”).
    • Note, this unique coupon value would need to be generated internally upon the user placing the order and then dynamically included in this event.
  3. The email/sms message template in the flow would contain an event personalization variable to dynamically populate this unique code, which the user could then send to a friend.
    • Alternatively, instead of displaying the code in the email, you could link to a landing page where the user could more easily share the referral gift to their friend via email, whatsapp etc. (I’d opt for this approach)
    • In the email the friend receives would be their unique code
  4. (Optional) You could create additional events that would trigger when the customer sends the referral to their friend (e.g. “Referral Sent”) and when the friend redeems the referral code. For example, when the friend redeems the referral code and places an order, a “Redeemed Referral” event would trigger for the friend’s profile and a “Referral Completed” event would trigger for the original customer’s profile.
    • This could then allow you to track number of Referral Completed events etc. and build a more robust referral/loyalty program.

Please let me know if you have any follow-up questions to the above.


Badge +1

HI thanks for the replies!

@StefanUE my plan for the referred friend is for them to enter the code at their own sign up so that will be stored in a Profile Property. What I do need is to be able to store/attach the referral code to the referrERs record so I can (manually at first I assumed) match the uses of their code back to them, not just to the code itself. I think that adding a generated voucher code to an email sent to the referrer to use, maybe doesn’t specifically attach the code to them, would I be right?

@Bobby I definitely need to keep costs down as we’re in pre-launch with no guarantee of actual launch at this stage! So the event would have to be triggered by sign up, or some other flow that happens following sign up from a specifc form/being added to say ‘Waitlist’ list. My follow up to you is similar, can this referral code created by the event be attached to the referrer for matchback later? And also, event creation sounds like it might be a developer job, is that right?


Userlevel 5
Badge +18

@pop_lou thanks for clarifying! 

I’ll address the follow up you directed at me.

You can check out the discount history on an individual profile level to see which dynamic codes were assigned to each person. Check the screenshot below for the exact location of this information on the profile dashboard.

From there, you should be able to manually connect the person that used the code (you can see this in Shopify) with the person the code was assigned to (in Klaviyo).

This is VERY MUCH not scalable, but it sort of does what you want it to do.

Hope this helps, happy to chat further!

Badge +1

@StefanUE thanks for confirming and I tested out being able to see the coupon on the profile - great! Now. Is there a way to update/create a Profile Property called eg ‘Referrer Code’ and populate the property value by using something like the string used in an email to show the code to the recipient {% coupon_code 'UniqueReferrer' %} (where UniqueReferrer is the name of the code!).

Does Klaviyo even allow that kind of use of tokens?

Userlevel 4
Badge +19

@pop_lou got it - thanks for providing the additional information. Considering you’re at the pre-launch stage, I’d expect the method Stefan outlined to be more feasible to start.

If/when the approach becomes too manual, that’s when a third-party app built for referrals might be a good fit. A few that I’ve seen mentioned in the space that could be worth checking out are Friendbuy, Social Snowball and ReferralCandy.

To respond to your follow-up questions:

Q. can this referral code created by the event be attached to the referrer for matchback later?

I’m sure this is technically possible. However, in the approach I mentioned, it would require custom development to create automated matchback functionality. It’s possible the referral apps I mentioned offer this natively. If not mentioned on their sites, it’s a good question to ask their teams during a product demo.


Q. event creation sounds like it might be a developer job, is that right?

Correct, the approach I shared would require the assistance of a developer to create the custom event.

Please let me know if you have any follow-up questions, and good luck on the launch!