# Tag Every Mailchimp Subscriber From Your Site

> Adds tags such as "website" and the visitor's language to every subscriber Mailchimp for WordPress sends to Mailchimp, from forms and integrations alike, so you can segment by source.

- Type: PHP
- Runs: Run everywhere
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: mailchimp, newsletter, tags
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/mc4wp-tag-subscribers/

## Code

```php
$wpide_tags = array( 'website' ); // Tags added to every subscriber.

add_filter( 'mc4wp_subscriber_data', function ( $subscriber ) use ( $wpide_tags ) {
    if ( ! is_object( $subscriber ) ) {
        return $subscriber;
    }

    $lang = strtok( determine_locale(), '_' );
    if ( function_exists( 'pll_current_language' ) && pll_current_language() ) {
        $lang = pll_current_language();
    } elseif ( defined( 'ICL_LANGUAGE_CODE' ) && ICL_LANGUAGE_CODE ) {
        $lang = ICL_LANGUAGE_CODE;
    }

    $tags   = $wpide_tags;
    $tags[] = 'lang-' . sanitize_key( $lang );

    $subscriber->tags = array_values( array_unique( array_merge( isset( $subscriber->tags ) ? (array) $subscriber->tags : array(), $tags ) ) );

    return $subscriber;
} );
```

## Notes

Edit $wpide_tags. The language tag uses the site or WPML/Polylang language.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Tag Every Mailchimp Subscriber From Your Site" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
