Skip to main content

emails-by-powr-campaign-emails

Emails by Powr Campaign emails​

Example email campaign:

example_campaign: { # all campaigns need a recipients hash and an emails list from: 'POWr [email protected]', # optional; by default campaigns are from "Pilar [email protected]"

    recipients: { # required hash of conditions that recipients must meet to receive this email campaign

active: true, # these key-value pairs build SQL automatically
signed_up: 25.hours.ago, # recipient conditions must have at least one time-based condition
with_at_least: { apps: 2 }, # i.e. can do { pro_subscriptions: 3, object_related_to_user: integer }
with_at_most: { email_objects: 5 },
without: 'pro_subscriptions', # ['can also pass array', 'string name of any object related to user']
with: 'credit_cards',
ab_test: true, # automatically creates ab logs with values 'recipient' and 'control_group'
mutually_exclusive: { platform: 'shopify', premium_status: 'free' }, # EITHER shopify OR free user

# see "build_query" function in email_campaigns.rb for complete list of supported query conditions
},

emails: [ # list of "email" hashes containing highest level info about the emails

{ # this is the first email in this campaign - will be named 'example_campaign_0'

subject: 'Hey {powr_ranger_name}! Hopefully this makes building email campaigns easy AF',
preheader: "This is optional. What's a preheader you ask? 👉 https://goo.gl/vRxhWH",
discount: "discount's unique_id", # optional; will create discount for this user when email is sent
delay: 2.days, # optional; by default, emails are delayed by {email index}.days

elements: [ # campaign_email_template.html.haml builds content from this elements array
{ title: { text: 'What's up {powr_ranger_name}!' } },
{ image: {
src: "#{aws}/powr/email_images/dope_image.png",
href: "#{powr}/pricing?app_type={last_app_slug}",
}
},
{ p: { text: "We use sparkpost for sending. {sparkpost_vars_are_wrapped_in_handlebars}", } },
{ p: { text: "Define sparkpost variables in 'get_users_with_sparkpost_data' method", } },
{ p: { text: "If using emojis in email body, ensure they're in 'handle_emojis' method 💯", } },
{ p: { text: "<a href='#'>You <em>can</em> include html in text for links and shit.</a>", } },
{ p: { text: 'You can also pass custom styling!', style: 'color: {users_favorite_color}' },
{ pricing_table: pricing_table_section( plans: ['enterprise'] ) },
{ button: { text: "Get more POWrful now!", href: "#{powr}/users/me" } },
{ pilar_outro: true } # see campaign_email_template.html.haml for complete list of email elements
{ blog_teaser: false } # true by default
]
},

{ # second email in example campaign - will be named example_campaign_1

from: '[email protected]', # from can be overridden on a per-email basis
recipients: { platform_not: 'wix' }, # emails within campaigns can have augmented recipient conditions
subject: '{powr_ranger_name}, this is the second email in the Example Campaign!',
template: 'email_2', # this email uses email_2.html.haml instead of campaign_email_template.html.haml

# since delay is not provided, this will send 1 day after query
},

... # can provide arbitrarily many emails and the price will still only be 1 query!
],
},

When you're done creating your email campaign, restart your server and go to https://localhost:3000/admin/powr-mail to see a preview. There you can send a test email, view raw sql, etc.