Support

Home Forums MailChimp Integration Mailchimp automation

Mailchimp automation

Posted: March 3, 2016 at 3:02 pm


ephemerapaducah

March 3, 2016 at 3:02 pm

Hello, I’m trying to set up MailChimp automation to send out a reminder email 5 days before an event, and I found a thread saying to add the date picker field to a registration – but I don’t want the user to have to choose the date that the event is on… that doesn’t’ make sense.

Is there a way to pass the event date to MailChimp?

Thank you!

Nikki


Tony

  • Support Staff

March 4, 2016 at 7:16 am

Hi Nikki,

There’s a hook available within the MailChimp Add-on that allows you to alter the details sent to MailChimp, that is:

FHEE__EE_MCI_Controller__mci_submit_to_mailchimp__subscribe_args

MailChimp passes the subcription arguments, datetime and EVT_ID to that filter so you can do something like this:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/addons/eea-mailchimp/tw_eea_mailchimp_start_date.php

You can add that to a functions plugin to pass the value over.

That function pulls all of the datetimes assigned to a ticket (as you can have more than 1) and uses the next upcoming datetimes start_date. You’ll also need to add a merge var to your MailChimp list called EVENTDATE – http://take.ms/FVVkq

Your subscribers will then have the date like this – http://take.ms/PLnIU

Is that what you need?


ephemerapaducah

March 4, 2016 at 10:13 am

That sounds like exactly what I need! Now let me work though it and see if I can get it to work. Thank you!!


ephemerapaducah

March 4, 2016 at 12:27 pm

Okay, so I’ve done the things listed above: added an EVENTDATE merge var to the list, set up a functions plugin and put in the code – but my date is not getting passed. Am I missing a step somewhere?


Lorenzo Orlando Caum

  • Support Staff

March 4, 2016 at 4:42 pm

Hello,

This functionality was introduced in a recent version of MailChimp for Event Espresso 4. What version are you using?

You can check in your plugins screens in your WP dashboard.

I’ve just tested and it transferred over the eventdate:

http://cl.ly/0R2v0L3F3T2n –> http://cl.ly/471G0U350I2A


Lorenzo


Tony

  • Support Staff

March 4, 2016 at 4:46 pm

Are you using the latest version of the MailChimp Add-on? (currently 2.3.2)


ephemerapaducah

March 4, 2016 at 5:03 pm

Yes, I’m using 2.3.2 and I just tested it again and it didn’t work 🙁

Is there anything I need to within the event itself to get it to recognize the eventdate? It’s sending over my name and email, but no event date.

Thanks!


Lorenzo Orlando Caum

  • Support Staff

March 6, 2016 at 9:12 am

Hello,

How was the sample function that Tony shared added to your site?

Is it through a site specific plugin? If so, could you verify that it is enabled?


Lorenzo


ephemerapaducah

March 6, 2016 at 4:33 pm

I used the instructions he shared here (https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/) to create a side specific plugin, and yes, it is activated.

As far as I can tell, I followed the instructions exactly. I’d be happy to share screenshots if there’s something you need to see that would help!

Thanks.


Lorenzo Orlando Caum

  • Support Staff

March 6, 2016 at 5:29 pm

Hi, could you provide us with a copy of the file as a zip?

You can upload to Dropbox and post it here and we’ll take a look.

Thanks!


Lorenzo


ephemerapaducah

March 6, 2016 at 6:41 pm

Here is the exact file that is being used for the site specific plugin: https://www.dropbox.com/s/mne2wo7mavyebyh/ephemera-customizations.php.zip?dl=0

Thanks!

Nikki


Tony

  • Support Staff

March 7, 2016 at 2:41 am

Hi Nikki,

That plugin looks fine, so we’ll need to do a little digging.

In the event have your selected the list that added the merge var to? The event date merge var you created should be showing in the list of available vars, like this – http://take.ms/ilY9r

Can you take a screen shot of your merge list vars and post that here to please?


ephemerapaducah

March 7, 2016 at 10:23 am

Yep, got it in there: https://www.dropbox.com/s/x4f1ye6qiwy4zhb/Screen%20Shot%202016-03-07%20at%2011.21.23%20AM.png?dl=0


Tony

  • Support Staff

March 7, 2016 at 12:52 pm

Ok, that’s fine.

Can you also post a screenshot of your MailChimp list merge vars please.

MailChimp -> {List} -> Settings -> list field and merge tags.

It should look like this – http://take.ms/byitD

It’s the merge tag that’s important on this step.


ephemerapaducah

March 7, 2016 at 6:28 pm

Yep, it looks the same: https://www.dropbox.com/s/10zcxovxp9de05e/Screen%20Shot%202016-03-07%20at%207.21.55%20PM.png?dl=0


Tony

  • Support Staff

March 8, 2016 at 3:32 am

Hmmm, that should all work fine.

Can you link me to the event you are testing this with please?

One way to confirm if the function is working is to write the contents of $subsribe_args to file before returning it.

Add this:

if ( ! function_exists('write_log')) {
	function write_log ( $log )  {
		if( is_array( $log ) || is_object( $log ) ) {
			error_log( print_r( $log, true ) );
		} else {
			error_log( $log );
		}
	}
}

Into your plugin, outside of the above function.

Then add:

write_log( $subscribe_args );

Just before the

return $subscribe_args;

It should look like this – http://take.ms/yAUFZ

Then retest but make sure WPDebug is on enabled and using this code:

define( 'WP_DEBUG', TRUE );
if ( WP_DEBUG ) {
	define( 'WP_DEBUG_LOG', TRUE );
	define( 'WP_DEBUG_DISPLAY', TRUE );
	define( 'SCRIPT_DEBUG', TRUE );
}

That will then write the contents of $subscribe_args to /wp-content/debug.log

It should looks something like this:


Array
(
    [apikey] => xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    [id] => 2c54e7ae27
    [email] => Array
        (
            [email] => mc008@example.com
        )

    [double_optin] => 
    [merge_vars] => Array
        (
            [EMAIL] => mc008@eventespresso.com
            [FNAME] => Tony
            [LNAME] => Warwick
            [EVENTDATE] => 04/05/2016
        )

)

If that’s all working then the function is pulling in the datetime and adding it into your subscribe calls as expected.


ephemerapaducah

March 8, 2016 at 11:40 am

Here’s the test event I set up to try this: http://181.224.139.71/~artpaduc/ephemerapaducah.com/events/event-test-multiday/

I’ll try the other suggestion you gave me now.


ephemerapaducah

March 8, 2016 at 12:46 pm

Okay, we are getting somewhere! The only weird thing now is that even though I have it set to read the date as MM/DD/YY (https://www.dropbox.com/s/godx6amt3dfk4l2/Screen%20Shot%202016-03-08%20at%201.33.05%20PM.png?dl=0), it is coming into the list as DD/MM/YY (https://www.dropbox.com/s/2mdmngrdtcobozw/Screen%20Shot%202016-03-08%20at%201.32.48%20PM.png?dl=0).

Any thoughts?


Tony

  • Support Staff

March 8, 2016 at 2:41 pm

What was the problem? (The additional code I provided above doesn’t fix anything it just writes the contents to file to work through and see if the date was added to the subscribe vars)

The only weird thing now is that even though I have it set to read the date as MM/DD/YY

The code I provided above passes the event date to MailChimp using the format d/m/Y which is DD/MM/YYYY

$merge_vars['EVENTDATE'] = $datetime->start_date( 'd/m/Y' );

So the merge vars will always display that format, I think the date format selection within MailChimp itself allows you to specify the format that will be used by default when/if you actually use the merge var *|EVENTDATE|* however I’m not entirely sure, the documentation is a little lacking so I would recommend contacting MailChimp themselves for more information.


ephemerapaducah

March 8, 2016 at 2:56 pm

Honestly, I have no idea what the problem was, and I’m not sure it’s totally fixed. I tested it with a new event from what I was testing before and it works on the new one, but not the old one. So I need to test it on more events to be sure it’s really working.

I just switched the d/m/Y to m/d/Y and that worked!! The choosing it within Mailchimp did NOT make it work. But it’s working now.

Now I have to test more events. Thanks so much for your help so far!!


Tony

  • Support Staff

March 9, 2016 at 2:45 am

I just switched the d/m/Y to m/d/Y and that worked!!

Within the this list your mean?

It will work because now your passing over the date in that format.

The choosing it within Mailchimp did NOT make it work. But it’s working now.

The dropdown will not change the output within the list, I suspect it is for when you actually use the merge var within a mailchimp campaign.

As in MailChimp lets you do *|EVENTDATE|* within a campaign and then outputs the date for each subscriber. I suspect that whatever date format you select within the dropdown will be used when you use that marge var in the campaign. However again I’m not sure as the MailChimp documentation doesn’t provide any useful information on what it is for.

Now I have to test more events. Thanks so much for your help so far!!

You’re most welcome.

Not that the function pulls in the datetimes where the DateTime Start date is greater than or equal to the current date. Looking at your previous event that should have worked there too, strange that it didn’t.

The support post ‘Mailchimp automation’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso