DEV Community

Derrick Sherrill for WayScript

Posted on

Simple Analytics on Email Mailing Lists using Python


Ask any marketer, all email addresses and leads are not the same. There's a huge difference between and signing up for your email mailing list. Performing analytics programmatically on third party email mailing lists can be tough work. Asking your marketing team to do it? No chance. In this tutorial, let's take a look at how we can programmatically set up an analytics system that takes in your leads and gives you access to write your own analytics.


No prerequisites but some content you might find helpful:

Integrations on WayScript

You may be familar with other integration as a service platforms that make it easy for users to connect APIs on one platform. WayScript is often confused as an IaaS tool from those who briefly look at the platform, however the functionality provided by WayScript is unrivaled. To put it simply, yes we do make it easy to integrate APIs on WayScript. But the big kicker is that we're providing an environment to build tools, rather than just integrating third party services together.

Take this email marketing example, WayScript does make it easy to import mailing list contacts from services such as mailchimp, sendgrid, and more. But the value proposition isn't connect X with Y when this happens. The value proposition is take X data as a variable, work with it in a prebuilt programming environment that you team has access to, and create tools to automate the work in the future. We provide the sand, you get to make your own sand castles.

Working with X Data

Right, so we've covered how we make it easy to pull data from other services, creating them as variables in WayScript. Now let's talk about using this data. In this example, since we're trying to do analytics on a mailing list. Let's write some python code. You can customize this as you see fit, we'll just find the most often used domains to sign up to the mailing list:

email_list = variables['email_list']
new_email_list = [] 
for i in email\_list:
    placeholder = i.split("@") 
count_occurences = [[x, new_email_list.count(x)] for x in set(new_email_list)] 
target_email_list = [i for i in email_list if '' in i] 

variables['target_email_list'] = target_email_list

If you're unfamiliar with python, don't let this code scare you. All we're doing is creating a couple new lists from an old one. Those two lists being the domains of the users in our email mailing list, and then a list of everyone who used an '' domain to sign up.

Sweet, Sweet, Automation

Data is awesome! But it's worthless if you don't know how to use it. Python scripts are great! But they're a waste of time if they never get ran, just sitting in your code directory. WayScript makes it easy for great python scripts to become great useful python scripts.

Execution of scripts on wayscript happen whenever the a trigger in your tree returns true. Sometimes this is when a certain time comes, other times it's upon a push event. In this example, you may want to create new lists when new emails are added. You could set up triggers to do that, or much more. The sand is limitless, build as big of a sand castle as you want.

Example Script

If you want to see a script of this example, it is available on our marketplace found here.

Top comments (0)