Great module! Quick question: I'm trying to use Mailchimp to do list segmentation according to the user's role. I looked at the available merge variables and I didn't see a user's Role listed anywhere.

Is there any way to make the user's role available as a field in Mailchimp (perhaps via the user or token modules)?

Thanks,
Ben

Comments

BenK’s picture

I was able to get access to the user's role by installing the Role Weights (http://drupal.org/project/role_weights) module. The Role Weights module automatically exposes the user's role as a Token, which is then available in the merge fields list to use with the Mailchimp module.

Hope this helps someone else!

--Ben

levelos’s picture

Status: Active » Postponed

The problem is that a user can be in more than one role, so the value of that merge field can only be a string where as a users roles is an array. The array can be exploded into a comma delimited string, but I'm not sure this makes sense. What we could do is restrict the roles var to only being matched to an interest group in MC.

BenK’s picture

Hey LouBabe,

Thanks for the comment. I suppose that mapping roles to interest groups could work (and also give you the ability to e-mail someone based any of the user's multiple roles).

An alternate approach by the Role Weights module is to rank your roles from lightest (highest priority) to heaviest (lowest priority). The module exposes both the lightest and heaviest roles as a token. So in my current setup, I pass along the lightest role as a variable to Mailchimp. I only get to specify one user role, however.

--Ben

levelos’s picture

Status: Postponed » Closed (won't fix)

BenK - The module is already designed to segment roles into different newsletters, so adding another layer via interest groups might add some confusion. I'm going to table this for now, but can revisit if needed.

nwe_44’s picture

Category: support » feature
Status: Closed (won't fix) » Active

This would be very useful to me, in fact, it would be excellent if there were some way to sync with the Mailchimp groups functionality as well

levelos’s picture

Status: Active » Closed (won't fix)

nwe_44 - Not sure about the reference to MailChimp Groups, but at the least that's an unrelated issue. As mentioned in this thread, any module can make additional tokens available via hook_mailchimp_merge_vars / values.

wickwood’s picture

There's a good reason to be able to add the User Roles to your Mailchimp subscriber data because Mailchimp charges you for the total number of subscribers from all of your lists. So if you have people on your site with multiple roles, you really don't want to add them multiple times to your Mailchimp account with different lists for each role. Being able to segment your list based on Drupal User Roles not only will save work, but also money.

Anyways, today I ran into this problem and needed to find some way to add the user roles to data for a given subscriber.

Fortunately, I found this post with a patch in the issues for the Token Module:
Token for user roles: post #5

I then added a simple hidden text field to my Mailchimp List Form from within Mailchimp and from the Drupal Mailchimp Module Settings page on the site linked the [roles-names] token to it.

This will work as long as you don't have a list of roles longer than 255 characters.

And I'll admit it's really a hack, and I'm sure it would be better to add this patch to the Mailchimp module itself rather than hack the token module, but it works for now.

Now I just need to figure out how to get the Location Module tokens to show up in the Mailchimp Settings, but that's for a different day and thread!

Hope this helps!
Steve

P.S. Hope you choose to change the status from "Won't fix" to "Needs Work". ;-)

Exploratus’s picture

subscribe...

beifler’s picture

I second Wickwood - once we get close to the subscriber limit in MailChimp there can be huge jump in price. We often have people subscribed to multiple lists, and have to merge them back to a main list every now and then. - levelos - I'd be willing to sponsor this.

shunshifu’s picture

Component: Code » General

subscribe

shunshifu’s picture

Nice Hack. Worked for me in a pinch.
Sure would be nice to have groups as an option. Hope that happens