(*Just to be clear, when I say “randomly“, I’m referring to the method by which I select the recommendation to insert; the people I recommend are carefully chosen. 😊)

Effective email marketing is all about making your subscribers’ experience as rich as possible. The more useful and relevant you can make your messaging, the more likely people are to stick around.

I believe that by adding more value, my subscribers win

When I send out my weekly emails, I sometimes recommend people I believe can add value to my email subscribers.

Those I recommend aren’t necessarily involved in ’email marketing’ (in fact, most aren’t), but they are business-related in some way and add can value that complements what I provide.

For example, I have subscribers on my list who are B2B freelancers, and I believe they can benefit from the learnings of other non-email marketing-focused professionals, e.g. business coaches, content creators, and solopreneurs who have successfully managed to carve out a niche for themselves.

As a freelancer myself, I’m always keen to give as much support as I can to the freelance community, as it can be a challenging and lonely place to be.

How I use Liquid code to randomly recommend others

I combine two powerful features to produce my inline email recommendations;

  • Liquid templating language (created by Shopify, supported by ConvertKit)
  • ConvertKit’s ‘Recommendations‘ feature.

The Liquid templating language is a very powerful open-source project that many email service providers support, meaning we can leverage it in our emails.

Don’t worry too much about knowing (or learning) Liquid in detail, because in reality, we can often copy and paste what someone else has already created.

The curly braces and percentage symbols are what encapsulate the Liquid code.

The first line (below) creates a variable (called ‘min’) and assigns a value to it (‘1’).

Then next line of code repeats the previous one, but this time it’s creating ‘max’ and assigning the value of ‘5’.

Now, in this line of code (below), we’re creating the variable called ‘diff’ and assigning a value by doing a calculation of subtracting ‘min’ from ‘max’ (i.e. diff = (5 – 1), i.e. 4).

Next, we get Liquid to produce a random number for us by using a mathematical function called ‘modulo‘ whilst interrogating the current date (the use of ‘date’ is irrelevant, it’s purely being used as a variable to generate a new number for the randomiser).

In simple terms, the function produces a randomised number from (1,2,3, and 4 – these are the possible values when we subtract ‘min’ from ‘max’, i.e. 5 – 1 = 4 possibilities).

Now we take the value that had randomly been generated (it’s going to be 1, 2, 3, or 4) and assign it to the variable called ‘randomNumber’).

Okay, take a deep breath… you made it this far! (Btw, well done for sticking with me!)

Now, things get simple – we add 4 possible options to our email, each assigned one of the possible values, and then display the recommendation associated with that number.

So, we do a comparison check using the ‘==’ operator.

If it’s equal to ‘1’, show this one… if it’s equal to ‘2’, show this one… etc.

I always add a catch-all ‘else‘ so that no matter what happens, the email will still make sense.

And you must close the Liquid code by using the ‘endif’ tag.

Making it easily-accessible in every email

If you want to take your Liquid code to the next level, then build it inside a ‘Snippet‘.

If you’re not sure what ‘Snippets’ are, check out this article where I explain how to create them, and when to use them.

Let’s look at what this example looks like, inside a ConvertKit ‘Snippet’.

Once you have created your ‘Snippet’, you can use it as many times as you wish, in as many emails as you need, simply by inserting it into your email using the editor element;

Once you select the snippet, the entire content will be displayed inside your email.

⚡️What to do now…

Open up a new ‘Broadcast’ email inside ConvertKit and create your first little bit of Liquid code to see how it looks when you send the email. You can copy and paste the code I use in this article if you wish, but have a play around with it and find how you want to leverage its power in your system.

Have a go and let me know how you get on. 👍😊

John Bellingham
Email marketing strategist for aspirational freelancers.

If we haven’t already done so, let’s connect on LinkedIn.

The Thursday Email Club is a free group where freelancers level up their email marketing game with weekly ‘live’ webinars, workshops, and Q&As.


Share your love
John Bellingham
John Bellingham

Starting out as a software engineer over 30 years ago, I began working for large corporates before realising solopreneurship was my 'thing'. I've had many businesses over the years, which have taught me many lessons.

I now spend my time helping other small business owners to implement the strategies and tactics that worked for me, whilst avoiding all my expensive mistakes.

If you're a small business owner who's either starting or running a business, then connect with me and let's have a chat.

I love Formula 1® so that's always a good conversation starter if you need one! 🏁 🏎

Articles: 177