Adding to store mailing list with external api call

Hi.

I was wondering if someone could help me with my unique situation.

I am a developer and have build my own front end project whihc is my e-commerce store. I am using shopify as a Back End. I am making calls and it is gathering the data required so that I can use it on my front end. The framework I used for this is Next Commerce

The issue I am having is that I cannot find any information regarding adding users to my shopify mailing list via an external api call. I would need to add them via an api call from my front end as thats where my users will be.

Can someone help me and explain what api I would need to hit with what credentials?

Thank you

Arian

1 Like

I am in the exact same situation. All I can find is that you have to create a new customer profile, but what if I only want to capture an Email? The documentation about importing 3rd parting emails states it will create a customer with john or jane doe if no name is given.

Is there no way to just simply add an email to a mailing list? The campaign only shows subscribers that are existing customers.

@ariansamouie I have found a way to do this.

First you will need shopify admin api access, and between 1-3 calls (Depending on the user).

New customer (no email on file)

If a user opts in with an email, that is not on file, simply create a new customer with the email only and the email marketing consent options.

create customer api call documentation and example input:

{
    "input": {
        "email": "test3@example.com",
        "emailMarketingConsent": {
            "marketingOptInLevel": "SINGLE_OPT_IN",
            "marketingState": "SUBSCRIBED"
        }
    }
}

This will create a new customer with the name as the email and be added as a subscriber. If you need sms do the same as above but with smsMarketingConsent input.

Email Already assigned to Customer (editing an existing customer)

If a customer already exists with that email then the above call will error out. You will need to:

  1. Get customer object by email
  2. Call customerEmailMarketingConsentUpdate API call using the customer ID from first call.

I used a simple query to get the customer with email

query GetCustomer {
  customers(first: 1, query: "test@example.com"){
    edges{
      node {
        id
        firstName
        lastName
        email
        emailMarketingConsent {
          consentUpdatedAt
          marketingOptInLevel
          marketingState
        }
      }
    }
  }
}

NOTES:

I ran a test where I created a new customer, then purchased something with that email, which will fill in more information (address, name, etc). After order placed there were 2 customers with same email but after a couple of minutes they must have merged and only one. BUT I have the checkout setting that does not pre select the OPT IN marketing box. When the merge of the two customers happened it took the marketing settings from the 2nd one (where the box was unchecked). This made the new “merged” customer no longer subscribed.