statamic-rad-pack / mailchimp

Mailchimp integration for Statamic
https://statamic.com/addons/rad-pack/mailchimp
MIT License
18 stars 12 forks source link

A way to have dynamic tags? #75

Closed kristiana-s closed 2 years ago

kristiana-s commented 2 years ago

Currently tags can either be pre-selected from the tag list in the plugin CP config or hardcoded in the config file like so: tag = 'Some tag'

We have a client who wants to tag contacts on a form by form submission basis, where the tag would change depending on where the form was submitted. Would it be possible to allow dynamic tags based on a form field, even if it is just writing it directly into config. So something like: tag => '{mailchimp_tag}

edalzell commented 2 years ago

Sorry @kristiana-s not sure I understand. What do you mean by "where the form was submitted"?

kristiana-s commented 2 years ago

@edalzell So in the CMS there will be a field called 'tag name', which will get passed to the form. So different pages can have different values for 'tag name' and so depending on which page the form is submitted the 'tag name' value is different.

Hope that makes sense?

edalzell commented 2 years ago

You want to be able to choose a form field to use as the tag? The same way you enter a merge field?

kristiana-s commented 2 years ago

@edalzell Yes, I suppose so. Initially, I thought it would be ok to just be able to somehow specify the tag parameter in config as dynamic. But if it could be like merge field that would be better :)

edalzell commented 2 years ago

Done @kristiana-s set the tag_field and it should all work for ya.

kristiana-s commented 2 years ago

Sorry about delayed response, been a bit hectic.

That's great thanks, However, upon upgrading to v 2.8 I seem to be running into this issue if no tags are set:

Silentz\\Mailchimp\\Subscriber::tag(): Return value must be of type string, null returned

config for form looks like this

'audience_id' => 'xxxx', 'disable_opt_in' => false, 'check_consent' => false, 'consent_field' => 'consent', 'form' => 'newsletter_signup', 'primary_email_field' => 'email',

Prevents the form from submitting, Im guessing somewhere tags are required? Cleared config etc. Is something missing in config or otherwise? Downgrading to v2.7 submits

edalzell commented 2 years ago

Nice find!

kristiana-s commented 2 years ago

@edalzell thank you for the quick fix!! :)