EmailVerify LogoEmailVerify

Shopify Email Verification

Email checker for Shopify. Verify customer emails at checkout and in Shopify apps.

Защитите ваш магазин Shopify от фальшивых аккаунтов, уменьшите отказы писем о брошенных корзинах и улучшите коммуникацию с клиентами, проверяя email-адреса.

Зачем проверять email в Shopify?

ПроблемаВлияниеРешение
Фальшивые аккаунтыЗлоупотребление промо, мошенничествоПроверка при регистрации
Брошенная корзинаОтказы писем восстановленияПроверка перед отправкой
Уведомления о заказахНеудачная доставка обновленийПроверка при оформлении заказа
Маркетинговые кампанииНизкая доставляемостьОчистка списка клиентов

Методы интеграции

МетодЛучше дляСложность
Shopify FlowАвтоматизированных рабочих процессовНизкая
Shopify FunctionsВалидации оформления заказаСредняя
Стороннее приложениеПолного решенияНизкая
Пользовательское приложениеПолного контроляВысокая

Метод 1: Shopify Flow (Рекомендуется)

Используйте Shopify Flow для автоматической проверки email.

Проверка email новых клиентов

Создайте рабочий процесс для проверки email при регистрации клиентов:

Триггер: Customer created

Условие: Customer email is not blank

Действия:

  1. Отправка HTTP-запроса к EmailVerify
  2. Добавление тега клиенту на основе результата

Конфигурация Flow

Workflow: Verify New Customer Email

Trigger:
  Event: Customer created

Condition:
  - Customer email is not blank

Action 1:
  Type: Send HTTP request
  URL: https://api.emailverify.ai/v1/verify
  Method: POST
  Headers:
    - Authorization: Bearer YOUR_API_KEY
    - Content-Type: application/json
  Body: {"email": "{{customer.email}}"}

Wait:
  Duration: 1 second

Action 2:
  Type: Add customer tags
  Tags:
    - email_verified (if status = valid)
    - email_invalid (if status = invalid)

Проверка перед письмами о брошенной корзине

Workflow: Verify Before Abandonment Email

Trigger:
  Event: Checkout abandoned
  Delay: 1 hour

Condition:
  - Customer email is not blank
  - Customer does not have tag "email_invalid"

Action 1:
  Type: Send HTTP request to EmailVerify
  Body: {"email": "{{checkout.email}}"}

Action 2:
  Type: Branch
  If status = "valid":
    - Continue to abandonment email sequence
  If status = "invalid":
    - Add tag "email_invalid"
    - Do not send email

Метод 2: Валидация оформления заказа с Shopify Functions

Создайте Shopify Function для валидации email при оформлении заказа.

Шаг 1: Создание функции Cart Transform

// extensions/email-validation/src/run.js
import { EmailVerify } from '@emailverify/node';

export function run(input) {
  const { cart } = input;
  const email = cart?.buyerIdentity?.email;

  if (!email) {
    return { operations: [] };
  }

  // Note: For real-time validation, use a pre-validated cache
  // or implement async validation via metafield
  return {
    operations: [],
  };
}

Шаг 2: Создание расширения UI оформления заказа

// extensions/email-validation-ui/src/Checkout.jsx
import {
  useExtensionApi,
  render,
  Banner,
  BlockStack,
} from '@shopify/checkout-ui-extensions-react';
import { useState, useEffect } from 'react';

render('Checkout::Contact::RenderAfter', () => <EmailValidation />);

function EmailValidation() {
  const { buyerIdentity } = useExtensionApi();
  const [validationStatus, setValidationStatus] = useState(null);

  useEffect(() => {
    const email = buyerIdentity?.email?.current;
    if (email) {
      validateEmail(email).then(setValidationStatus);
    }
  }, [buyerIdentity?.email?.current]);

  if (!validationStatus) return null;

  if (validationStatus.status === 'invalid') {
    return (
      <Banner status="warning">
        Please check your email address. It appears to be invalid.
      </Banner>
    );
  }

  if (validationStatus.result?.disposable) {
    return (
      <Banner status="info">
        We recommend using a permanent email for order updates.
      </Banner>
    );
  }

  return null;
}

async function validateEmail(email) {
  const response = await fetch('/apps/email-verify/validate', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ email }),
  });
  return response.json();
}

Метод 3: Пользовательское приложение Shopify

Создайте полное решение для верификации email.

Бэкенд приложения (Node.js)

// server/index.js
import '@shopify/shopify-app-remix/adapters/node';
import { shopifyApp } from '@shopify/shopify-app-remix/server';
import { EmailVerify } from '@emailverify/node';

const shopify = shopifyApp({
  // ... Shopify config
});

const emailVerify = new EmailVerify({
  apiKey: process.env.EMAILVERIFY_API_KEY,
});

// API route for email verification
export async function action({ request }) {
  const { email, customerId } = await request.json();

  try {
    const result = await emailVerify.verify(email);

    // Update customer metafield
    if (customerId) {
      await updateCustomerVerificationStatus(customerId, result);
    }

    return json(result);
  } catch (error) {
    return json({ error: error.message }, { status: 500 });
  }
}

async function updateCustomerVerificationStatus(customerId, result) {
  const { admin } = await shopify.authenticate.admin(request);

  await admin.graphql(`
    mutation updateCustomerMetafield($input: CustomerInput!) {
      customerUpdate(input: $input) {
        customer {
          id
        }
      }
    }
  `, {
    variables: {
      input: {
        id: `gid://shopify/Customer/${customerId}`,
        metafields: [
          {
            namespace: "email_verification",
            key: "status",
            value: result.status,
            type: "single_line_text_field"
          },
          {
            namespace: "email_verification",
            key: "score",
            value: String(result.score),
            type: "number_decimal"
          },
          {
            namespace: "email_verification",
            key: "verified_at",
            value: new Date().toISOString(),
            type: "date_time"
          }
        ]
      }
    }
  });
}

Обработчик вебхуков

Обработка вебхуков создания клиента:

// server/webhooks/customer-created.js
export async function handleCustomerCreated(topic, shop, body) {
  const customer = JSON.parse(body);
  const { id, email } = customer;

  if (!email) return;

  try {
    // Verify email
    const result = await emailVerify.verify(email);

    // Update customer with tags
    const tags = [];
    if (result.status === 'valid') {
      tags.push('email_verified');
    } else if (result.status === 'invalid') {
      tags.push('email_invalid');
    }
    if (result.result?.disposable) {
      tags.push('disposable_email');
    }

    await updateCustomerTags(shop, id, tags);

    // Store verification result
    await updateCustomerVerificationStatus(shop, id, result);

    console.log(`Verified ${email}: ${result.status}`);
  } catch (error) {
    console.error(`Failed to verify ${email}:`, error);
  }
}

Интеграция с темой (Liquid)

Добавление верификации в форму регистрации:

{% comment %} snippets/email-verification.liquid {% endcomment %}

<script>
document.addEventListener('DOMContentLoaded', function() {
  const emailInput = document.querySelector('input[type="email"]');
  const submitButton = document.querySelector('form[action="/account"] button[type="submit"]');

  let verificationResult = null;

  emailInput.addEventListener('blur', async function() {
    const email = this.value;
    if (!email) return;

    // Show loading state
    emailInput.classList.add('verifying');

    try {
      const response = await fetch('/apps/emailverify/verify', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ email })
      });

      verificationResult = await response.json();

      // Update UI based on result
      updateEmailFieldUI(verificationResult);
    } catch (error) {
      console.error('Verification failed:', error);
    } finally {
      emailInput.classList.remove('verifying');
    }
  });

  function updateEmailFieldUI(result) {
    // Remove existing messages
    const existingMessage = document.querySelector('.email-verification-message');
    if (existingMessage) existingMessage.remove();

    // Create message element
    const message = document.createElement('div');
    message.className = 'email-verification-message';

    if (result.status === 'invalid') {
      message.classList.add('error');
      message.textContent = 'Please enter a valid email address';
      submitButton.disabled = true;
    } else if (result.result?.disposable) {
      message.classList.add('warning');
      message.textContent = 'Please use a permanent email for account recovery';
    } else if (result.status === 'valid') {
      message.classList.add('success');
      message.textContent = '✓ Email verified';
      submitButton.disabled = false;
    }

    emailInput.parentNode.appendChild(message);
  }
});
</script>

<style>
.email-verification-message {
  font-size: 12px;
  margin-top: 4px;
}
.email-verification-message.error { color: #c9302c; }
.email-verification-message.warning { color: #f0ad4e; }
.email-verification-message.success { color: #5cb85c; }
input[type="email"].verifying {
  background-image: url('/path/to/spinner.gif');
  background-position: right 10px center;
  background-repeat: no-repeat;
}
</style>

Сценарии использования

1. Предотвращение регистрации фальшивых аккаунтов

Блокируйте одноразовые и невалидные email при регистрации:

// Theme app extension
async function validateRegistration(email) {
  const result = await verifyEmail(email);

  if (result.status === 'invalid') {
    return {
      valid: false,
      message: 'Please enter a valid email address',
    };
  }

  if (result.result.disposable) {
    return {
      valid: false,
      message: 'Temporary email addresses are not allowed',
    };
  }

  return { valid: true };
}

2. Восстановление брошенных корзин

Отправляйте письма о брошенных корзинах только на валидные адреса:

Shopify Flow:
  Trigger: Checkout abandoned (1 hour delay)

  Condition: Check email verification status

  If valid:
    → Send abandonment email
    → Add to remarketing audience

  If invalid:
    → Skip email
    → Log for analytics

3. Оценка риска заказа

Учитывайте качество email при обнаружении мошенничества:

function calculateOrderRiskScore(order, emailVerification) {
  let riskScore = 0;

  // Email verification factors
  if (emailVerification.status === 'invalid') {
    riskScore += 30;
  }

  if (emailVerification.result?.disposable) {
    riskScore += 20;
  }

  if (emailVerification.result?.free && order.total > 500) {
    riskScore += 10; // High value order with free email
  }

  // Other factors...
  if (order.billing_address !== order.shipping_address) {
    riskScore += 15;
  }

  return riskScore;
}

4. Сегментация клиентов

Создавайте сегменты клиентов на основе качества email:

СегментКритерииМаркетинговая стратегия
ВысокоценныеПроверенный, бизнес-emailПремиум-кампании
СтандартныеПроверенный, бесплатный emailОбычные кампании
Под угрозойНепроверенный, старый аккаунтКампания повторной верификации
ИсключенныеНевалидный, одноразовыйБез маркетинга

Настройка метаполей

Создайте метаполя для хранения данных верификации:

Метаполя клиента

mutation createMetafieldDefinitions {
  metafieldDefinitionCreate(definition: {
    namespace: "email_verification"
    key: "status"
    name: "Email Verification Status"
    type: "single_line_text_field"
    ownerType: CUSTOMER
  }) {
    createdDefinition { id }
  }
}

Рекомендуемые метаполя:

NamespaceKeyTypeОписание
email_verificationstatussingle_line_text_fieldvalid, invalid, unknown
email_verificationscorenumber_decimal0.0 - 1.0
email_verificationverified_atdate_timeДата последней верификации
email_verificationdisposablebooleanОдноразовый email
email_verificationrole_basedbooleanРолевой email

Доступ к метаполям в Liquid

{% if customer.metafields.email_verification.status == 'valid' %}
  <span class="verified-badge">✓ Verified</span>
{% endif %}

Массовая верификация клиентов

Очистите существующий список клиентов:

Экспорт клиентов

async function exportCustomersForVerification(admin) {
  const query = `
    query getCustomers($cursor: String) {
      customers(first: 250, after: $cursor) {
        edges {
          node {
            id
            email
            createdAt
            metafield(namespace: "email_verification", key: "status") {
              value
            }
          }
          cursor
        }
        pageInfo {
          hasNextPage
        }
      }
    }
  `;

  let customers = [];
  let cursor = null;

  do {
    const response = await admin.graphql(query, {
      variables: { cursor },
    });

    const { edges, pageInfo } = response.data.customers;

    // Filter unverified customers
    const unverified = edges
      .filter((e) => !e.node.metafield)
      .map((e) => ({
        id: e.node.id,
        email: e.node.email,
      }));

    customers.push(...unverified);
    cursor = edges[edges.length - 1]?.cursor;
  } while (response.data.customers.pageInfo.hasNextPage);

  return customers;
}

Массовая проверка и обновление

async function bulkVerifyCustomers(customers) {
  const emails = customers.map((c) => c.email);

  // Submit bulk verification job
  const job = await emailVerify.verifyBulk(emails);

  // Wait for completion
  const results = await waitForJobCompletion(job.job_id);

  // Update customers with results
  for (const result of results) {
    const customer = customers.find((c) => c.email === result.email);
    if (customer) {
      await updateCustomerVerificationStatus(customer.id, result);
    }
  }

  return results;
}

Лучшие практики

1. Проверяйте в нескольких точках

  • Регистрация: Блокировка фальшивых аккаунтов
  • Оформление заказа: Гарантия доставки уведомлений о заказе
  • Брошенная корзина: Не тратьте email на невалидные адреса

2. Кэшируйте результаты

Кэшируйте результаты верификации, чтобы избежать избыточных API-вызовов:

const CACHE_DURATION = 24 * 60 * 60 * 1000; // 24 hours

async function verifyWithCache(email) {
  const cacheKey = `email_verify:${email}`;
  const cached = await redis.get(cacheKey);

  if (cached) {
    return JSON.parse(cached);
  }

  const result = await emailVerify.verify(email);
  await redis.setex(cacheKey, CACHE_DURATION / 1000, JSON.stringify(result));

  return result;
}

3. Обрабатывайте крайние случаи

function handleVerificationResult(result, context) {
  switch (result.status) {
    case 'valid':
      // Normal flow
      break;

    case 'invalid':
      if (context === 'checkout') {
        // Don't block checkout, just log
        logInvalidEmail(result.email, 'checkout');
      } else if (context === 'registration') {
        // Block registration
        throw new Error('Invalid email');
      }
      break;

    case 'unknown':
      // Accept but flag for review
      flagForReview(result.email);
      break;

    case 'accept_all':
      // Valid but monitor for bounces
      markAsCatchAll(result.email);
      break;
  }
}

4. Мониторинг и оптимизация

Отслеживайте эти метрики:

  • Показатель успешности верификации
  • Снижение показателя отказов
  • Показатель предотвращения фальшивых аккаунтов
  • Доставляемость писем о брошенной корзине

Связанные ресурсы

On this page

Зачем проверять email в Shopify?Методы интеграцииМетод 1: Shopify Flow (Рекомендуется)Проверка email новых клиентовКонфигурация FlowПроверка перед письмами о брошенной корзинеМетод 2: Валидация оформления заказа с Shopify FunctionsШаг 1: Создание функции Cart TransformШаг 2: Создание расширения UI оформления заказаМетод 3: Пользовательское приложение ShopifyБэкенд приложения (Node.js)Обработчик вебхуковИнтеграция с темой (Liquid)Сценарии использования1. Предотвращение регистрации фальшивых аккаунтов2. Восстановление брошенных корзин3. Оценка риска заказа4. Сегментация клиентовНастройка метаполейМетаполя клиентаДоступ к метаполям в LiquidМассовая верификация клиентовЭкспорт клиентовМассовая проверка и обновлениеЛучшие практики1. Проверяйте в нескольких точках2. Кэшируйте результаты3. Обрабатывайте крайние случаи4. Мониторинг и оптимизацияСвязанные ресурсы