eladnava/mailgen

Add 'one click' actions to email subject lines

Closed this issue · 4 comments

Incorporate the Gmail schemas to allow users to perform 'one click' tasks such as confirm a subscription or unsubscribe from a list etc.

Published Google documentation for these schemas and functionality are at: https://developers.google.com/gmail/markup/reference/one-click-action

Hi @CyberFerret, what an excellent suggestion!

I read up on the One Click Actions, and it seems these are more for one-time interaction. What happens under the hood is that Gmail will execute an HTTP request on behalf of the user to the target confirmation URL, so this only makes sense for "Confirm your account" transactional mail.

However, I then found Go-To Actions.

Go-To Actions take the user to your website where the action can be completed. Unlike One Click Actions, go-to actions can be interacted with multiple times.

screen shot 2016-05-27 at 12 23 41 pm

I think we should go with implementing Go-To Actions, specifically, ViewAction.

What do you think about this?

Personally I think the ViewAction should definitely be included for tracking purchases via the "successful purchase" email.

@SJTreadway do you mean tracking packages?

Yeah, that would be awesome.

I'm thinking about simply using the body.action data provided to mailgen to generate the Go-To Action (by default it will be disabled but we can add a flag like body.action.goToAction: true to turn it on).

@CyberFerret @SJTreadway It's ready.

You can make use of Gmail's Go-To Actions within your e-mails by suppling the goToAction object as follows:

var email = {
    body: {
        // Optionally configure a Go-To Action button 
        goToAction: {
            text: 'Go to Dashboard',
            link: 'https://mailgen.com/confirm?s=d9729feb74992cc3482b350163a1a010',
            description: 'Check the status of your order in your dashboard'
        }
    }
};

However, note that you need to get your sender address whitelisted before your Go-To Actions will show up in Gmail.