• Resolved Simone Montanari

    (@semikola)


    Hi there,

    I need to target my Audience based on the page they subscribed from.

    So I’d like to add the page slug to as TAGS for my new subscribers.

    Following this example I tried this code:

    function mc4wp_add_tags( MC4WP_MailChimp_Subscriber $subscriber ) {
        global $post;
        
        $subscriber->tags[] = $post->post_name;
        return $subscriber;
    }
    add_filter( 'mc4wp_subscriber_data', 'mc4wp_add_tags' );

    Unfortunately it doesn’t work, could you help?

    Thanks,

    Simone

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Lap

    (@lapzor)

    I can’t help you with custom code like this, but I recommend to test it with
    $subscriber->tags[] = ‘test-tag’;
    and if that works you know that the problem is in getting the post name.

    How about (in the form):

    <input type="hidden" name="YOUR-FIELD-NAME" value="{current_path}">

    I guess the downside is this field will be overwritten each time…

    Thread Starter Simone Montanari

    (@semikola)

    Hi Lap,

    thanks for the answer, the problem is indeed in getting the post name. But I stil haven’t figure out why it doesn’t work.

    Anyway thanks for your suggestion.

    Simone

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add page slug to Mailchimp tags’ is closed to new replies.