statamic-rad-pack / mailchimp

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

Subscribers not being added to the audience #52

Closed MikeHarrison closed 3 years ago

MikeHarrison commented 3 years ago

Hi,

I have the addon installed and running locally, and believe I have everything set up correctly. However when I fill in my form, the subscribers are not being added to Mailchimp.

What is the best way of diagnosing what is happening here? Thanks for any help - please let me know if I can provide any futher info.

Mike

edalzell commented 3 years ago

Let's see your config file

MikeHarrison commented 3 years ago

Sure (API key is in there on the real thing):

mailchimp.php

<?php

return [

    /*
     * If you want to add to your mailchimp audience when a user registers, set this to `true`
     */
    'add_new_users' => true,

    /*
     * The form submissions to add to your Mailchimp Audiences
     */
    'forms' => [
        [
            'audience_id' => 'aaed3f7760',
            'disable_opt_in' => false,
            'check_consent' => false,
            'consent_field' => 'consent',
            'form' => 'mailchimp',
            'merge_fields' => [
                [
                    'tag' => 'NAME',
                    'field_name' => 'name',
                ],
                [
                    'field_name' => 'email',
                    'tag' => 'C_EMAIL',
                ],
            ],
            'tag' => null,
        ],
    ],
    'api_key' => '******************************',
];
edalzell commented 3 years ago

And let's see the form fieldset please.

MikeHarrison commented 3 years ago

This is the fieldset that is added by the page builder:

newsletter_signup.yaml

title: 'Newsletter Signup'
fields:
  -
    handle: heading
    field:
      input_type: text
      display: Heading
      type: text
      icon: text
      listable: hidden
  -
    handle: outro_text
    field: common.text_basic
    config:
      buttons:
        - bold
        - italic
        - unorderedlist
        - orderedlist
        - removeformat
        - anchor
        - superscript
      display: 'Outro Text'
      instructions: 'The small piece of text that appears after the signup form'
  -
    handle: thank_you_message
    field: contact_form.thank_you_message
    config:
      buttons:
        - bold
        - italic
        - unorderedlist
        - orderedlist
        - removeformat
        - anchor

This is my mailchimp.yaml in resources/blueprints/forms:

sections:
  main:
    display: Main
    fields:
      -
        handle: name
        field:
          input_type: text
          display: 'Name'
          type: text
          icon: text
          listable: hidden
      -
        handle: email
        field:
          input_type: email
          display: Email
          type: text
          icon: text
          listable: hidden
          validate:
            - required

And this is the _newsletter_signup.antlers.html which is in resources/views/page_builder/

<div class="container text-darkblue">
    <h2 class="
    mb-4
    font-light text-xl md:text-2xl lg:text-3xl xl:text-4xl text-center
    col-span-12
    sm:col-span-10 sm:col-start-2
    ">
      {{ heading | widont }}
    </h2>
    <div class="col-span-12 sm:col-span-10 sm:col-start-2 mb-4">

      {{ form:mailchimp class="md:flex md:items-end md:justify-around" }}
        {{ if success }}
        <div class="prose text-darkblue text-center text-xl">
          {{ thank_you_message | widont }}
        </div>
        {{ else }}

        <div class="mb-8 md:mb-0 flex-grow md:mx-2 lg:mx-4">
    <label for="name" class="block mb-1 text-darkblue">Name:</label>
    <input class="shadow-none w-full transition duration-200 bg-white p-2 rounded-lg focus:outline-none border border-mono-200 focus:border-darkblue" type="text" id="name" name="name" value="{{ old:name }}" />
  </div>

  <div class="mb-8 md:mb-0 flex-grow md:mx-2 lg:mx-4">
    <label for="email" class="block mb-1 text-darkblue">Email Address:<span class="text-red-700 ml-1">*</span></label>
    <input required="required" class="shadow-none w-full transition duration-200 bg-white p-2 rounded-lg focus:outline-none border border-mono-200 focus:border-darkblue" type="email" id="email" name="email" value="{{ old:email }}" />
  </div>

  <div class="md:mx-2 lg:mx-4">
    <button class="focus:outline-none inline-flex items-center uppercase w-auto text-white text-center bg-darkblue px-4 py-2 rounded-lg hover:bg-lightblue hover:border-lightblue transition duration-200 border border-darkblue">Send</button>
  </div>

    {{ /if }}

  {{ /form:mailchimp }}

    </div>
    <div class="col-span-12 sm:col-span-10 sm:col-start-2">
      <div class="prose text-center mx-auto text-sm text-darkblue">
        {{ outro_text }}
      </div>
    </div>
</div>

Sorry, more information than you asked for but thought I would try and cover everything!

edalzell commented 3 years ago

how are you testing? You've got disable_opt_in set to false so Mailchimp will send a confirmation email first, are you getting those?

MikeHarrison commented 3 years ago

I am filling in the form, which looks to be submitting as the message in the {{ if success }} is appearing. Then nothing else happens - no email from Mailchimp, and nothing in the Mailchimp dashboard to indicate anything has happened.

edalzell commented 3 years ago

Can you please zip up your site and send it to me?

edalzell commented 3 years ago

@MikeHarrison please update and try again.

edalzell commented 3 years ago

merge fields were required.