1

Our checkout is only for registered users.

Ideally you'd just provide a checkbox that says: Subscribe to Mailchimp?

Any ideas?

2

We offer this during checkout.

We use André Elvan's: https://github.com/aelvan/mailchimp-subscribe-craft

We implement it simply as an ajax call that happens in the background as the order is submitted for payment:

    if ($('#subscribeMC').prop('checked')) {
        // Fire this off asynchronously and with any luck it just works...
        $.ajax({
            type: 'POST',
            url: '/actions/mailchimpSubscribe/list/Subscribe',
            data: {
                CRAFT_CSRF_TOKEN: window.csrfTokenValue,
                email: email,
                mcvars: {
                    FNAME: firstName,
                    LNAME: lastName,
                }
            }
        });
    }

One thing I like about our implementation is that I added a 'check if subscribed' function to the above plugin and we only show the checkbox if they're not already on the list - it's one of my pet hates when I keep seeing a newsletter box for a list I know I am already on.

$.ajax({
    type: 'POST',
    url: '/actions/mailchimpSubscribe/list/checkIfSubscribed',
    data: {
        'CRAFT_CSRF_TOKEN': window.csrfTokenValue,
        'email': email
    },
    success: function(response) {
        //They're on the newsletter - hide the subscription form
        if (response.success) {
            $container.hide();
            $heading.hide();
        }
        //They're not on the list, bait the hook
        else {
            $container.fadeIn('fast');
            $heading.fadeIn('fast');
        }
    },
    //something went wrong, might as well show the form
    error: function(response) {
        $container.fadeIn('fast');
        $heading.fadeIn('fast');
    }
});

If you wanted to avoid JS/ajax, then I guess you could implement your own controller that you submit to at any point (e.g. intercept the commerce pay controller) - that first does your Mailchimp stuff and then calls the native controller using Craft's runController.

But the above JS works well and we get a bunch of newsletter subs with it every day...during subscribe checkout is by far the most effective way of increasing your mailing list we've found. (And, please, whatever else you may do, do not implement a page covering newsletter signup popover!!)

3
  • Thanks a lot Jeremy. Obviously your solution is part of a bigger js strategy. So I've replaced the variables $container with $('#my-containter-div') eliminated the $heading variable and changed email with ''{{ cart.email }}' and also deleted the mcvars part, since I only want the email. Now I get two bad Requests in the console: jquery-1.11.1.min.js:4 POST mydomain.com/actions/mailchimpSubscribe/list/checkIfSubscribed 400 (Bad Request) and POST local.ingwerer.at/actions/mailchimpSubscribe/list/Subscribe 400 (Bad Request). Do you know what could be causing that? – outline4 Jun 7 '17 at 11:25
  • Now that I come to think of it... Maybe I have to wrap the form around my checkbox? – outline4 Jun 7 '17 at 11:28
  • Sorry I did not see these...did you get this working ok? – Jeremy Daalder Jun 16 '17 at 0:30
1

Just to follow up on this, we created a plugin that adds email addresses (+ First & Last Name) to a MailChimp list whenever the user starts the process of an order:

https://github.com/madebyshape/mailchimp-commerce

👍

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.