We’ve recently started using ConvertKit for our email marketing for Stitch People, and I LOVE IT. It’s flexible, easy to create automation sequences (called courses), easy to move people in and out of courses based on any number of events (purchase, link click in an email, etc.), easy to tell exactly which form someone signed up on, and much more.
The first step in my migration to ConvertKit was to start collecting new subscribers and customers into ConvertKit, and to tag them automatically for easy segmentation later. This included writing a small Shopify app to automatically subscribe customers and tag them based on what they purchased. I’ll write another post about this later.
Once all new subscribers were being funneled into ConvertKit instead of Mailchimp, it was time to clean up old data. The first place I started was to tag past Shopify customers based on the product they purchased. We have a relatively small number of products right now (different variants of a book is our main product), but this would work just as well for a large catalog of products and customers.
To do this, I’ll be using the ConvertKit API (documentation found here).
Step 1: Create the tags in ConvertKit
The main API endpoint we’re going to be hitting is the Add Subscriber to Tag endpoint. And since the API doesn’t support creating new tags yet, you’ll need to create these tags through the website first. Head to the Subscribers area, and click ‘Create Tag’ at the bottom of the right sidebar. That’ll bring up the box to create a new tag.
You can come up with your own naming convention for tags, but my general rule of thumb is to be descriptive. You may know what an obscure tag means when you create it right now, but your 6-months-from-now self won’t, and you’ll kick yourself when you have a bunch of people tagged, but you don’t know why.
For example, I use tags like ‘diy-physical-book’ and ‘diy-ebook’ to differentiate between two different variants of the DIY Stitch People book. I prefixed it with ‘diy’ because we’ll be releasing more books later, for which we will have physical and digital copies. For those, I’ll create tags like ‘farm-animals-physical-book’ and ‘zoo-animals-ebook’. These will be easy to decipher down the road.
Step 2: Grab your list of customers from Shopify
Next, head to Shopify and do an export of all your orders. Head to the Orders tab, and hit the Export button at the top. Make sure you select the All Orders radio button, and export the orders, not transaction histories. I use the CSV for Excel, Numbers, etc. option. I’ll eventually be uploading this to Google Drive.
Step 3: Make separate lists of email addresses for each tag
This will likely be the most time-intensive step in this whole process. Now you need to take the CSV from Shopify and filter through several times to generate lists of email address for each tag you want to apply. For me, I created three lists: one for physical book purchasers, one for ebook purchases, and one for physical + ebook purchases. These are the three tags I’m using, and now I need to come up with three separate lists of email addresses–one for each tag.
For this step, I used Google Spreadsheets. You could also use Excel, Numbers, or any other spreadsheet program that lets you quickly and easily filter your table based on column contents. Once you have your CSV file loaded in whatever application you’re using, you need to filter the table by products/variants. In Google Spreadsheets, you can use the Filter feature and then select the ‘lineitem_name’. In my case, I’ve been through several different iterations of the product and variation titles, so for my ebook DIY book buyers, I had to select several values:
Once filtered, copy those email address and throw them into a new tab in the spreadsheet. Make sure you label the tab so you know which list you have. Repeat this step for any other tags you want to apply.
Step 4: Write the script to tag the subscribers
Now comes the fun part. You can choose whatever language you want, as long as you have a way to make an HTTP POST request. I chose Ruby and used Faraday. Here’s a gist:
First thing you’ll want to do is populate the arrays of email addresses. Take the email address lists from your individual spreadsheet tabs and format them as strings in an array. I used a text editor (Atom) to quickly do this, then just pasted in the result. I was dealing with about 2,000 email addresses total.
Once you’ve created the arrays, head to your ConvertKit account page to find your API key. Put that value in.
Finally, you’ll need to grab your ConvertKit tag ids and populate those into the URL strings. Head to ConvertKit, click on the tag you want, and grab the ID from the URL:
Put that value in for the XXXX between ‘tags’ and ‘subscribe’ for each tag.
Step 5: Run the script
Now it’s time for the magic. Save the file you’ve been editing and then run it. For Ruby, I just opened a terminal window, navigated to the folder where the file was, and typed ‘ruby filename.rb’ to run it. Mine took about 10 minutes to run to completion. Once that was done, all my subscribers were properly tagged with the product they had purchased, allowing me to create Courses and Segments based on those tagged subscribers.