WordPress and WooCommerce guide — Mailkoo Skip to content
Log in Live demo Get started
Set up & connect

WordPress and WooCommerce

Show your pop-up forms on a WordPress site, and add every WooCommerce buyer to a list automatically so you can follow up with emails.

Find it in: Integration → Websites, API (and your WordPress dashboard) 15 steps

You connect WordPress to your account in two parts. You can do one or both:

  • Pop-up forms on your site — paste your website's tracking code into WordPress once. After that, the pop-up forms you publish appear on your site and new sign-ups go straight into your list. No coding.
  • WooCommerce buyers into a list — add a short, ready-made code snippet to WordPress. Every time an order is paid, the buyer is added to the list you choose, with their name and a tag such as customer. A returning buyer who is already on the list gets the tag.

There is nothing to install from us. Both parts use WPCode, a free WordPress plugin for adding code to a site without editing theme files.

What you can do with WordPress and WooCommerce

Pop-up forms on WordPress

Your published forms appear on every page of your WordPress site.

No theme editing

The free WPCode plugin holds the code, so theme updates never remove it.

Buyers join a list

Each paid WooCommerce order adds the buyer to your list with their first and last name.

Tag every buyer

Buyers get a tag, so you can send them their own emails and segments.

Follow up automatically

A Tag based automation can thank buyers and send a series after each purchase.

Install the WPCode plugin

You do this once in WordPress. Both parts of this guide use it.

  1. Find WPCode in WordPress

    In your WordPress dashboard, go to Plugins → Add Plugin (1). (Older WordPress versions call it Add New Plugin or Add New.) Type WPCode in the Search Plugins box (2).

    The result you want is WPCode – Insert Headers and Footers + Custom Code Snippets – WordPress Code Manager. Click Install Now (3), and then Activate.

  2. Open Code Snippets

    After activation, a new Code Snippets menu appears in the WordPress sidebar (1). You use two of its pages: Header & Footer for the tracking code, and + Add Snippet for the WooCommerce code.

Show your pop-up forms on WordPress

Your pop-up forms appear on a site after you add the site under Websites and paste its tracking code into the site.

  1. Add your WordPress site

    In your account, go to Integration → Websites and click Add website. Type your WordPress site's full address in Website URL, including https://, and click Add website.

  2. Copy the tracking code

    The website page opens with a Connection box. The Tracking code (1) is one line that starts with <script id="ACXConnectScript". Click the copy button (2).

  3. Paste it into the footer in WordPress

    In WordPress, go to Code Snippets → Header & Footer (1). Paste the tracking code into the Footer box (2), then click Save Changes (3).

    WPCode adds the code to every page of your site, just before the closing </body> tag.

  4. Check that the site is connected

    Open your site in a new browser tab, so the code runs once. Then go back to Websites and reload the page. A green Connected badge (1) means it works.

    Still Inactive? Clear your site's cache (caching plugins such as WP Rocket, LiteSpeed Cache or W3 Total Cache keep the old page) and open the site again, or click Connect on the website page.

  5. Publish a form on the site

    Open Forms, open a form in the builder, connect it to your WordPress site and publish it. The Forms guide shows each step.

    Visitors then see the pop-up on your site, according to the form's display settings, and everyone who signs up goes into the form's list.

Add WooCommerce buyers to a list

A snippet in WordPress sends each buyer to your account when their order is paid: when the order status becomes Processing or Completed. Each order is sent once.

You need three things from your account: the API endpoint, your API token and the UID of the list the buyers should join.

  1. Copy the API endpoint and your API token

    Go to Integration → API. At the top, click Copy next to Your API token (1). Under Getting started, copy the API endpoint (2): your app address followed by /api/v1.

    Keep both in a note for a moment. The Integrations guide explains this page.

  2. Copy the list UID

    Open Lists and click the list your buyers should join. You may want a new list, for example Shop customers.

    Look at the address bar of your browser: the list UID is the code after /lists/ (1). Copy it.

  3. Add a new PHP snippet in WordPress

    In WordPress, go to Code Snippets → + Add Snippet (1). Point to the first card, Add Your Custom Code (New Snippet), and click + Add Custom Snippet.

    The Create Custom Snippet page opens and asks you to Select the code type for your snippet. Click PHP Snippet (2).

  4. Paste the code and fill in your details

    Give the snippet a title, for example Send buyers to my email list (1). Copy the code below and paste it into Code Preview (2). Then replace the three values at the top with your own:

    • https://your-app-address/api/v1 → your API endpoint
    • YOUR_API_TOKEN → your API token
    • YOUR_LIST_UID → your list UID

    Keep the quote marks around each value. You can also change the tag customer to any word you like.

    // Send every paid WooCommerce order's buyer to an email list.
    add_action( 'woocommerce_order_status_processing', 'my_email_list_add_buyer' );
    add_action( 'woocommerce_order_status_completed', 'my_email_list_add_buyer' );
    
    function my_email_list_add_buyer( $order_id ) {
        // Your details: replace these values.
        $api   = 'https://your-app-address/api/v1'; // API endpoint
        $token = 'YOUR_API_TOKEN';                  // Your API token
        $list  = 'YOUR_LIST_UID';                   // List UID
        $tag   = 'customer';                        // Tag for every buyer
    
        $order = wc_get_order( $order_id );
        if ( ! $order || $order->get_meta( '_email_list_added' ) ) {
            return; // Already sent.
        }
    
        $email   = $order->get_billing_email();
        $headers = array(
            'Authorization' => 'Bearer ' . $token,
            'Accept'        => 'application/json',
        );
    
        // A new contact: add them to the list with their name and the tag.
        $response = wp_remote_post( $api . '/subscribers', array(
            'headers' => $headers,
            'body'    => array(
                'list_uid'   => $list,
                'EMAIL'      => $email,
                'FIRST_NAME' => $order->get_billing_first_name(),
                'LAST_NAME'  => $order->get_billing_last_name(),
                'tag'        => $tag,
            ),
        ) );
    
        // Already on the list: find them and add the tag.
        if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
            $found = wp_remote_get( $api . '/subscribers/email/' . rawurlencode( $email ), array( 'headers' => $headers ) );
            $data  = json_decode( wp_remote_retrieve_body( $found ), true );
            foreach ( (array) ( $data['subscribers'] ?? array() ) as $contact ) {
                if ( $contact['list_uid'] === $list ) {
                    wp_remote_post( $api . '/subscribers/' . $contact['id'] . '/add-tag', array(
                        'headers' => $headers,
                        'body'    => array( 'tag' => $tag ),
                    ) );
                }
            }
        }
    
        $order->update_meta_data( '_email_list_added', 1 );
        $order->save();
    }
    
  5. Activate and save the snippet

    Scroll down to Insertion and leave Auto Insert and Run Everywhere as they are.

    At the top, switch the toggle from Inactive to Active (1) and click Save Snippet (2). If WPCode finds a mistake in the code, it tells you and does not switch the snippet on. Check that the quote marks around your values are still there.

  6. Test it with an order

    Place a test order in your shop with your own email address, or open an existing order under WooCommerce → Orders (1) and change its status to Processing (2). Click Update.

  7. See the buyer in your list

    In your account, open the list and go to Subscribers. The buyer is there with their first and last name and the status Subscribed. To see tags in the table, click Columns (1), tick Tags and click Apply: the buyer has the tag customer (2). A returning buyer keeps the tags they already had.

    Not there? Check the three values in the snippet: the API endpoint ends with /api/v1, the token was copied in full, and the list UID belongs to this list. After a fix, test with an order that has not been sent yet, because each order is sent only once.

The snippet sends buyers from new orders only. To add the customers you already have, export them from WooCommerce as a CSV file (WooCommerce → Customers → Download) and import them into the list.

Send buyers a follow-up automatically

Because every buyer gets a tag, you can start an automation when the tag is added: a thank-you email, a review request a week later, or a tip on using the product.

  1. Create a Tag based automation

    Go to Automation and click New Automation. Choose the Tag based trigger, and under Audience tick the list your buyers join.

    In Trigger settings, type the same tag as in the snippet, for example customer, and click Create automation. Then add your emails and waits in the flow editor, and switch the automation on. The Automation guide shows each step.

    Type your buyers' tag, for example customer, in Tags.

Common questions

Is there a WordPress plugin I need to install from you?

No. You paste your website's tracking code and, for WooCommerce, the snippet from this guide into WordPress. The free WPCode plugin, or any similar plugin you already use, holds both.

Do buyers get a confirmation email first?

Only if the list uses Double opt-in (in the list's Settings). Then a new buyer is added as Unconfirmed and receives the confirmation email, and automations start for them only after they confirm. Without it, buyers are added as Subscribed straight away.

May I email everyone who buys from my shop?

That depends on the law where you and your buyers are. In many countries you need the buyer's consent before you send marketing emails. If you are not sure, turn on Double opt-in for the buyers' list, or tell buyers at checkout that they will receive your emails and how to unsubscribe.

A buyer unsubscribed earlier. Will a new order subscribe them again?

No. The snippet only adds the tag to a contact who is already on the list, so their status stays Unsubscribed.

Does this work with the new WooCommerce checkout block and with any payment method?

Yes. The snippet listens to the order status, not to the checkout page, so it works with the classic checkout, the checkout block and every payment method that marks orders Processing or Completed.

My pop-up does not show on my WordPress site.

Check that the website shows Connected under Websites, that the form is connected to that website and published, and clear the cache of any caching plugin. With the First visit only display trigger you see the pop-up only once, so open the site in a private window to see it again.