How to build an in-email streak counter with AI
Shockingly simple way to create tech tools, gadgets, or even games
Strap in.
Grab a cup of coffee.
You'll want to spend some time with today's guest post from John Bejakovic.
If you don't know who John is, he writes a daily email newsletter about direct marketing, copywriting, and his love for the books and screenplays of William Goldman.
A lot of big-name business owners and marketers read his emails every day (including America's copy king, Gary Bencivenga). In December, he launched the Daily Email Habit newsletter—to make daily emails feel like a game, so you stick with this habit for the long term.
And in today's deep dive, John's going to walk you through how he created an in-email streak counter with AI.
Here's John:
Email newsletters are a simple and enjoyable way to write online. And paid email newsletters can even be a profitable online business.
But there’s a problem. And that's getting newsletter subscribers to regularly open, read, and consume your content.
If subscribers won’t open and read your newsletter, they won’t get value out of what you write. And if they don't get value from what you write, they won't stay subscribed for long, particularly if they have to pay.
I faced this problem last month, when I launched a new service called Daily Email Habit.
Daily Email Habit is effectively a paid, daily newsletter. Every day, Daily Email Habit gives business owners and marketers a new email prompt. The prompt serves as a starting point for subscribers to write their own email to their own email list. Here’s an example prompt:
A typical prompt inside a Daily Email Habit email
I wanted to encourage subscribers to not only open and read these daily prompts, but to act on them. To make that happen, I decided to introduce a bit of gamification. I took a strategy from learning apps like DuoLingo. Here’s how it works.
An in-email streak counter
At the bottom of each Daily Email Habit email, subscribers can press a big button. That button marks that they've written and sent their email for the day (scout’s honor). There’s also a streak counter, which displays how long of a streak a subscriber has kept up with his or her emails:
The streak counter at the bottom of each Daily Email Habit email
The result? Here’s a bit of feedback I got from a subscriber named Jakub Červenka. Jakub sells self-development courses online. He started writing daily emails to his email list, using the prompts in Daily Email Habit. He wrote me about his experience so far:
I also noticed how not wanting to break the streak is motivating me - even more so than I don’t know, say making potentially money from making a sale to my list… that’s crazy. I am ashamed to admit it, as it is completely irrational, but it’s the truth. And probably not so surprising to anyone in the copywriting world, we know we are not rational beings, but still, this surprised me.
Like Jakub says, this bit of gamification can be very motivating. It rewards subscribers for taking action. It trains readers to open my emails because they don’t want to break the streak. It makes them more likely to benefit from the ideas in my newsletter.
Of course, that’s good for me also:
It keeps open rates sky high and helps with deliverability
I get feedback on who my most engaged subscribers are
It makes it more likely subscribers stay subscribed for longer
How complicated is this to do?
Services like ConvertKit or Substack won't give you an in-email streak counter. If you want something like this in your newsletter, you’ll have to do some wizardry on your own.
The good news is, you don’t need programming knowledge or tech skills. That’s because AI can do it all for you, and guide you through the whole process.
In this article, I'll walk you through how I did exactly this. I chatted with ChatGPT, and got it to do all the work of creating this bit of gamification in my newsletter.
I got it to explain my options. I got it to answer my tech questions. I got it to do all the programming I would never have done on my own.
By the end of this article, you will know how to create an email streak counter in your own newsletter. I'll also give you all my code and instructions on how to use it. If you use ConvertKit for email and Bluehost for web hosting, you can drop in my code and have it work in 2 minutes’ time.
But what if you don’t use ConvertKit? Or what if you don’t have Bluehost?
Don’t worry. There’s a bigger point to this article. I want to show you the high-level process I used to get ChatGPT to guide me and work for me. I want to show you how to do the same, even if you use a different email provider or a different web host.
I also want to stretch your mind a bit. If you want to modify my email streak counter... or create a different kind of gamification... or come up with an entirely new tech tool for yourself and your subscribers... then this article will show you how easy and fast that can be, thanks to AI. So let's get started.
Step 1: Get ChatGPT to explain my options
I had a clear idea of how I wanted my email streak counter to look. But I had no idea of how to make it happen, particularly inside of an email. So I started a new chat with ChatGPT to figure out what my options are. My very first prompt was:
Step 1: Maybe somebody’s already done this for me?
I won’t reprint the whole chat thread here. The gist was, I went back and forth with ChatGPT for a few more messages. I explained to ChatGPT:
What I want (an email streak counter, as described above)
What resources I already have (for example, a web hosting account with Bluehost)
What I don’t want (an expensive or complicated tech solution, or a subscription I have to pay for)
It turned out, there wasn’t a plug-and-play solution I could simply use. But ChatGPT gave me a possible solution that would work for me:
ChatGPT proposes a “straightforward” solution
In short, ChatGPT told me I could use my Bluehost web hosting account to host a little web script. If the script were written in the PHP programming language, I could just drop it in and it would work automatically, like this:
A schema of what ChatGPT was proposing to me
The fact is, I don’t know how to write PHP scripts, and I didn’t want to do any programming myself for this project. That’s okay. ChatGPT was willing to do all the work for me.
Step 2: Click to update the streak
At this point, I had just given a description of how I wanted my streak counter to work. I had also figured out the tech environment I wanted to use. With just these two bits of information, ChatGPT was already ready to get to work. I simply asked it:
All the prompt engineering it took to get ChatGPT to program a script for me
That’s all I had to do. As a result, ChatGPT cheerfully produced a 110-line PHP script. The fact is, I would never have taken the time or trouble to figure out how to write this script myself. But ChatGPT did it for me in just a few seconds.
Step 3: Upload to Bluehost
The next step was to put this script on my Bluehost server. How to do this? ChatGPT was already ahead of me, and it gave me instructions on what exactly to do, even without me asking:
ChatGPT walks me through what to do with the script it’s just written for me
I followed these instructions. Within 10 minutes of starting this entire project, I was already getting somewhere.
The PHP script that ChatGPT had written for me was sitting inside my Bluehost account. That meant it was accessible via the web. I could simply call it via a URL.
In other words, I could put a link inside my email, formatted as a button, which would call this script when clicked. The script would access and update a local database that stored user streaks.
After the script was done, it would show the following web page. If you look close, you can see the email streak (1) for a dummy user (user@example.com), in a data format known as JSON:
A functional but ugly first draft of the result page
Step 4: Show success page
This was clearly a step in the right direction. But the technical printout above was not what I wanted to show to subscribers for real. So I told ChatGPT what I wanted to do instead:
Asking ChatGPT to create a nicer V2 of the result page
ChatGPT modified the initial PHP script it gave me to show a results page like I asked. I uploaded the new version to BlueHost using the same approach as in step 3.
I also updated the image to show a still from a Looney Tunes cartoon because I found it fun and lighthearted. With this new script, when a subscriber clicks the button in the email, the following page appears:
The final version of the result page
I had one more issue:
Up to this point, I had just been using a placeholder email in the URL. Of course, I wanted each user to see his or her own streak, not a placeholder. In order to do that, I’d need to add their email address to the URL in the button.
In ConvertKit, this is done with the “{{ subscriber.email_address | url_encode }}” shortcode:
Passing the subscriber’s email address from the email to my streak tracking script
Step 5: Show the streak in the email
At this point, I already had a functional streak tracker. Users could click the button at the bottom of the email to keep their streak going. This opened up a webpage that shows them their current streak.
Of course, I still hadn't done the most tricky part. After all, a button and a webpage that show the streak are nice. But what I really wanted was to show the streak inside the email. This way, subscribers who open the email would want to keep their streak alive.
But is that even possible? Could I somehow include data from my own BlueHost account in an email that’s sent out by ConvertKit? I had no idea. So once again, I asked ChatGPT:
I ask ChatGPT to guide me through a tricky step of my email streak counter
As ChatGPT informed me, email as a tech platform is very limited. A normal web page or an app can run local scripts or call remote servers. But an email in your inbox cannot.
Fortunately, emails can load images from URLs. ChatGPT explained how I could use this as a workaround:
I could add a new PHP script to my BlueHost account
This script would take a subscriber’s streak and generate an image on the fly that shows that streak
I could then show that image inside my email
Let me pause to once again repeat the crucial point:
There’s no way I would ever have bothered to write this image-generation code if I had to figure it out myself. But it was super easy with ChatGPT. In fact, I didn’t even have to ask — ChatGPT already wrote up a script for me as soon as I asked if it was possible:
ChatGPT writes a script to dynamically turn text into an image
Yes, it took a bit of fiddling until the streak image looked exactly how I wanted. But that fiddling was really just more talking to ChatGPT. After tweaking the color and the font, the resulting streak image looked like this:
A dynamically generated image that shows a user’s streak
Again, I uploaded this second script to BlueHost using the same process as in Step 2 above. I now had a second URL I could call from my email, which would return a PNG image that showed a user’s streak.
In ConvertKit, I could use an HTML snippet to show an image. This source for this image would be the URL of my PHP script:
Adding in an HTML image tag in ConvertKit, which calls my PHP script for the streak image
The result of all this work was that I had a working streak counter. A user could click on the button to update it. My script on BlueHost would update the user’s streak if 24 hours had passed since the previous update. And the user could see his updated streak in the next email, like this:
The result of all of ChatGPT’s hard work
Step 6: Reset the streak if they don't click
There was one last piece. If a subscriber didn’t click on the streak button within 24 hours, I wanted the streak to be reset to 0. I explained my goals to ChatGPT, and it told me what to do:
Asking ChatGPT to help me with the last step of the email streak counter
In short, ChatGPT explained I’d need a third script. This script would be run every 24 hours by a “cron” job within my BlueHost account. Basically, this was a way to schedule a script to run at a set time, every day.
As you can guess by now, I had no idea how to do this. Again, ChatGPT gave me the new script. And as usual, it told me how to go on Bluehost and schedule this script to run regularly:
Another patient, detailed response from ChatGPT, walking me through the next step
I did as ChatGPT told me. And with this third and final script, I was done!
Users could now see their streak in each email. They could click on a button to keep their streak going. And if they didn’t click the button in the 24 hours after my email went out, then their streak would be reset to 0.
Triumph! Except of course…
Step 7: Uh oh… there's a bug
I launched Daily Email Habit on Monday, November 25, 2024. The streak counter worked brilliantly for the first 24 hours. And then, by mid-afternoon on Tuesday, I started to get complaints:
Bug reports pour in for version 1 of my email streak counter
On closer look, It turned out I had done a bad job telling ChatGPT what to do. ChatGPT, obedient and responsible as it is, did exactly as I told it to do.
My mistake was telling ChatGPT that the streak could only be updated once every 24 hours. That was just flat-out wrong.
For example, a user could click to update their streak at 5pm on Monday and 2pm on Tuesday. That’s less than 24 hours apart, And yet, it should be perfectly fine. In this situation, the streak should be updated, but in the first version of the code, it was not.
I realized I should have told ChatGPT something different. The streak should only be updated once in every 24-hour block, starting from the time my daily email went out.
So I went in explained my mistake to ChatGPT, and I told it to rewrite the first script I had created:
I give ChatGPT more thoughtful instructions for creating the streak tracker
Once again, ChatGPT politely and patiently rewrote my PHP script. I uploaded it to BlueHost. And with this change, I really was finished.
My paid newsletter, Daily Email Habit, has been running for almost three weeks now. The streak counter has worked flawlessly ever since. Subscribers are using the streak counter and are getting hooked. As a result, they are opening, engaging with, and benefitting from my newsletter.
If you want to copy exactly what I’ve done…
I’ve shown you how I got ChatGPT to create a bit of tech magic for me, and guide me through every step of setting it up.
If you like, you can take the code that ChatGPT has written up for me and drop it into your own hosting provider. It should work out of the box. You can find the code below, along with instructions on how to deploy it on BlueHost:
Click here to download the full code and instructions for the streak tracker
But what if you don’t use BlueHost? Or anything like BlueHost?
I could try to write up a general guide for how to get set up online so you can have a place to run little scripts like this.
But that guide wouldn't be as good as simply pointing you to ChatGPT. You can ask and get feedback that’s customized to your specific situation. If you need a starting point, here’s what I asked it, which resulted in a world of good options, both paid and free:
ChatGPT offers advice about BlueHost replacements for hosting your tech tools
This leads me to the final point of this article.
If you DON’T want to copy exactly what I’ve done…
Perhaps you don't want to copy my streak counter, the way I had ChatGPT create it. Maybe you want to do something a little different, or something very different. That’s great. In fact, it’s the bigger point I hope to get across to you.
ChatGPT now makes it shockingly easy and quick to create little tech tools or gadgets or even games.
Come across a cool engagement trick in your favorite app? Or see a neat tool on your favorite website?
ChatGPT can help you create it for your own business, and for your own audience. All you have to do is ask.
Here’s a prompt to help you get started:
Keep reading with a 7-day free trial
Subscribe to Write With AI to keep reading this post and get 7 days of free access to the full post archives.