How to create a referral program using Drip email marketing service

1. Create an email containing a link with subscriber id in it with Liquid shortcode {{ }}
2. Capture the id from url and apply a tag based on it with Google Tag Manager making a Javascript API request

Referral program is widely known but utterly underused marketing tactic, where you ask your current customers to promote your product or service. Referral program is often adjoined with gamifying techniques where current customer earns badges, vouchers or psychological gains to encourage desired action.

Probably the most known company to do this is Dropbox, where users get additional storage for free (yep, it was a referral link), if they get new people to sign-up to Dropbox users.

Drip is an email marketing service (another referral link) built around drip email campaigns. Giving it a short tour, you might think it is way too simple for a proper company to use. But combining tags, rules, workflows and easy-to-use Javascript API, it is a powerhouse at your service.

Let’s start.

You have a landing page with a sign-up form. And you want your current customers to invite their friends to it.

In order to credit the current customer with referred new customers we need to accomplish three things

  1. get subscriber specific information as a referral id
  2. save the referral id to new subscriber’s properties
  3. find matching pairs

For these instructions to work, you must have both Drip Javascript snippet and Google Tag Manager snippet installed to your landing page. It doesn’t matter if you’re using form widget or embedded form (or even a non-Drip form) as long as the form is on a landing page on your website.

But it does not work, if the form is hosted on Drip’s domain.

1. Have your current subscriber give a referral id to his friends

The easiest way to create a subscriber specific information is to use the user id already stored in Drip subscriber information.

Note: if you viewed Subscriber Properties and the User ID is empty, don’t worry, the user still has an id. It’s just not visible.

Take your referral program promoting email and the link to your landing page. In addition to the actual url, we’re going to add the referral id as an parameter. Like this:{{ }}

Naturally the part before the question mark (?) should be changed to your domain and your landing page path.

After the question mark we declare a parameter named ”ref” and assign a value to it. Instead using the actual id, we prefix it with ”re” just to be sure not to mess with the actual id and also because we need it in a validation phase later on.

Don’t worry, nobody will know the difference.

Note: If you want to use Google Analytics campaign variables, you can do that too. Just make sure you only have one ? in your url and all variables are separated with an AND operator (&).

Now, take a Preview of your email and use the Preview as a subscriber function. If you either click the link or just hover your mouse above it, you can see what the actual url is.

Click to enlarge

It should now be something like this:

Try different subscribers and you should see the ?ref=re part being different each time.

You have got yourself a subscriber specific web address and we’re ready for the next part.

2. Save the referral id into new subscriber’s Properties

This part is two-folded: First we will catch the parameter as soon as possible. And then we’ll do the actual saving with a little delay to ensure Drip has received the new subscriber.

Catch the parameter with Google Tag Manager and save it into variable

I’m not going into too much details how to install and use Google Tag Manager here on this blog post.

We are going to create a variable, a trigger and a tag.

They all have their respective folders on the left hand side of the user interface. Click the item and there will be a red ”NEW” button on the page.

If you need further help, just give me a holler and I’ll try to find a resource for your.

First, create a new User-Defined Variable.

As the Variable type is URL, you might want to take that into consideration when naming the variable. Let’s name the variable ”URL ref”. Component type is ”Query” and Query Key is the ”ref” we declared in the url in the earlier part.

Note: Naming variables, triggers and tags with a consistent method is really important to make it easier to find them later from the alphabetized list.

What we have now is the variable being saved from url as soon as page is loaded.

Push the variable as a Tag into Drip with Google Tag Manager

Second, create a new Trigger.

As the Trigger type is Form submission, you might want to name the Trigger as ”Form Subscription”. Check the Wait for Tags checkbox and put 10000 into Max waiting time.

This ten-second (10000 milliseconds) delay will give Drip more time to catch the submission and create the new user into subscriber database.

Note: There’s no validation whether the email address looks like a real one. Drip will validate it though, and will ask the user to try again on a Drip domain submission page, where we don’t have Google Tag Manager running. For that reason too, a proper delay is a good idea.

Because of the delay, it is also recommended to use other validation methods until we let the trigger do its job. For this reason, let’s check that we actually have some information in the URL ref variable.

From the ”Enable this trigger when all of these conditions are true” drop down menu combination select ”URL ref” ”starts with” ”re”.

Let’s then tackle the actual triggering rule from the ”This trigger fires on”.

As we only want this to happen on landing page form, select the radio button from right hand side ”Some Forms”. And from the menus below select ”Page path” ”contains” ”landing-page”.

Note: The page-path does NOT contain the protocol, domain or the parameters in the complete url. Just the part in the middle.)

What we have now is the trigger that launches the action (what we haven’t done yet), when a user submits a form on our landing page, after a ten-second delay.

Third, create a new Tag

As we’re doing a Drip related tag with an API functionality performing tagging, you might want to name the tag as ”Drip API Tag Referrer”.

Although we’re going to do javascript, the Tag type is Custom HTML. And the code goes as follows:

_dcq.push(["identify", {
tags: ["ref-{{URL ref}}"]

This makes an API request to Drip saying:

”Yo, Drip! This cookie here needs to be applied with the tag ’ref-resmnm5if6xxx7stprspje’.” [Naturally changing the id part as appropriate.]

Note that this script doesn’t care if the user is identified or not. If Drip hasn’t identified the user yet, the shout will never be heard and the tag is never applied.

We could, however, add the email address from the form into this request. But that’d require us also to validate the address, and I’d rather not do it.

Remember to assign the ”Form subscription” trigger we just created above. And also remember to Publish your changes in Google Tag Manager (I always forget that part).

Let’s recap

If all is good, what should happen is, that

  • every ”person” (i.e. a browser with a cookie)
  • submitting the form
  • on the landing page
  • with the url containing the id parameter
  • would be tagged with ”ref-re” prefixed user id tag.

Now, you should be able to search all the new users having a tag starting with ”ref-re”.

And, if your subscibers already have the User ID field set, you can also find the matching original users with the user id.

Simply head up to Subscribers and Filter subscribers with ”User ID” ”equals” ”smnm5if6xxx7stprspje” (or whatever the actual id might be).

But, for most cases the User ID field is empty and you can’t find the original subscriber whose id we just  nicely have tagged onto new referred subscribers.

Without that, the referral program is useless, so you have to do imminent one more thing.

3. Copy the User Id into Custom Field with an automated Rule to make it searchable

Although all users have user id, for some reason the information is not by default saved on Subscriber Properties. You can see it yourself on selecting any Subscriber and clicking the Properties tag.

If the User ID field is set, you’re lucky and should start to wonder if all subscribers have the same.

If not, please continue.

You can add user id into User ID field manually with uploading a CSV file containing the information but that is hardly the automated way we’re now trying to accomplish.

Another way is to make another Javascript API request, but we don’t want to do that either.

Instead we’re going to copy the subscriber id into a Custom Field with an automated Rule.

Click to enlarge
  1. Create a new rule clicking Automation > Rules > New Basic Rule
  2. As a trigger select Drip: Applied a tag
  3. Type a new tag name into Which tag dropdown: ”giveMeID
  4. As an action select Drip: Set a custom field value
  5. Type a new custom filed name into Custom Field Identifier dropdown: ”User_id”
  6. Type the Liquid shorcode {{ }} into Value field
  7. Click ”Save Rule”
  8. Remember to Activate the rule near the rule name

What we’ve now accomplished is a Rule that copies the subscriber id into User_id Custom field at the same time the user has been applied ”giveMeID” tag.

This is convenient for the old subscribers you already have on your list. Simply go to Bulk operations and apply everyone with the tag.

Click to enlarge

For new users you might want to alter the Rule to be triggered with any form submissions. As a trigger select Drip: Submitted a form and Which form: Any form.

This is again convenient only if all your subscribers come through Drip’s own forms. But if you upload users with CSV files or connect other form services (such as Contact Form 7) you need to have another trigger.

Perhaps you have one onboarding campaign to which people is always subscribed, regardless where they came from. That would be perfect trigger for copying the id into searchable field.

Another solution could be to integrate Drip with Drip using Zapier. This way you can apply the giveMeID tag to all new subscribers as soon as they’re subscribed.