EmailVerify LogoEmailVerify

Shopify

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

Shopify ストアに EmailVerify を統合し、チェックアウト、顧客登録、マーケティングワークフロー全体で顧客のメールアドレスを検証しましょう。

連携方法

方法最適な用途複雑さ
Shopify Flow自動化ワークフロー
カスタムアプリフル連携
Zapierノーコード自動化
Webhook注文後の検証

方法 1:Shopify Flow(推奨)

Shopify Flow を使用して、顧客作成時や注文時にメールを自動検証します。

Flow ワークフローの作成

  1. Shopify 管理画面で 設定Flow を開く
  2. ワークフローを作成 をクリック
  3. 以下のフローを設定:
トリガー: 顧客が作成された

アクション: HTTP リクエストを送信
    URL: https://api.emailverify.ai/v1/verify
    メソッド: POST
    ヘッダー:
      Authorization: Bearer YOUR_API_KEY
      Content-Type: application/json
    ボディ: {"email": "{{customer.email}}"}

条件: レスポンスの status が "invalid" と等しい

アクション: 顧客タグを追加 "email_invalid"

Flow テンプレート

顧客メール検証フロー

トリガー: Customer created

アクション: Send HTTP request
  URL: https://api.emailverify.ai/v1/verify
  Method: POST
  Headers:
    Authorization: Bearer {{shop.metafields.emailverify.api_key}}
    Content-Type: application/json
  Body: |
    {
      "email": "{{customer.email}}"
    }

条件分岐:
  If: response.body.status == "valid"
    アクション: Add customer tags "email_verified"

  If: response.body.status == "invalid"
    アクション: Add customer tags "email_invalid"
    アクション: Send internal email
      To: admin@yourstore.com
      Subject: 無効なメールで顧客作成
      Body: 顧客 {{customer.email}} のメールが無効です

  If: response.body.result.disposable == true
    アクション: Add customer tags "email_disposable"

方法 2:カスタムアプリ

完全な制御が必要な場合は、カスタム Shopify アプリを作成します。

アプリのセットアップ

// app/routes/webhooks.customer-create.jsx
import { json } from '@remix-run/node';
import { authenticate } from '../shopify.server';
import EmailVerify from '@emailverify/node';

const bv = new EmailVerify(process.env.EMAILVERIFY_API_KEY);

export const action = async ({ request }) => {
  const { topic, payload, shop } = await authenticate.webhook(request);

  if (topic !== 'CUSTOMERS_CREATE') {
    return json({ error: 'Invalid topic' }, { status: 400 });
  }

  const customer = payload;
  const email = customer.email;

  if (!email) {
    return json({ success: true, message: 'No email to verify' });
  }

  // メールを検証
  const result = await bv.verify({ email });

  // 顧客メタフィールドを更新
  await updateCustomerMetafields(shop, customer.id, {
    email_verification_status: result.status,
    email_verification_score: result.score,
    email_is_disposable: result.result.disposable,
    verified_at: new Date().toISOString(),
  });

  // 無効なメールの場合は顧客にタグを追加
  if (result.status === 'invalid' || result.result.disposable) {
    await addCustomerTags(shop, customer.id, ['email_risky']);
  } else {
    await addCustomerTags(shop, customer.id, ['email_verified']);
  }

  return json({ success: true });
};

async function updateCustomerMetafields(shop, customerId, data) {
  // Shopify Admin API を使用してメタフィールドを更新
}

async function addCustomerTags(shop, customerId, tags) {
  // Shopify Admin API を使用してタグを追加
}

チェックアウト拡張機能

Shopify チェックアウト拡張機能でリアルタイム検証を追加:

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

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

function EmailVerification() {
  const { email } = useEmail();
  const [status, setStatus] = useState(null);
  const [message, setMessage] = useState('');

  useEffect(() => {
    if (email) {
      verifyEmail(email);
    }
  }, [email]);

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

      const result = await response.json();

      if (result.status === 'invalid') {
        setStatus('error');
        setMessage('有効なメールアドレスを入力してください。');
      } else if (result.result?.disposable) {
        setStatus('warning');
        setMessage('恒久的なメールアドレスの使用をお勧めします。');
      } else if (result.status === 'valid') {
        setStatus('success');
        setMessage('メールが確認されました。');
      }
    } catch (error) {
      // エラー時は何も表示しない
      setStatus(null);
    }
  }

  if (!status) return null;

  return (
    <Banner status={status} title={message} />
  );
}

方法 3:Zapier 連携

コーディング不要で Zapier を使用して連携:

Zap の設定

トリガー: Shopify → 新しい顧客

アクション: Webhooks by Zapier → POST
    URL: https://api.emailverify.ai/v1/verify
    Headers:
      Authorization: Bearer YOUR_API_KEY
      Content-Type: application/json
    Data: {"email": "{{email}}"}

アクション: Shopify → 顧客を更新
    タグ: {{ステータスに基づいて設定}}

方法 4:Webhook 連携

注文作成後に検証する場合:

Webhook ハンドラー

// pages/api/webhooks/shopify/orders-create.js
import crypto from 'crypto';
import EmailVerify from '@emailverify/node';

const bv = new EmailVerify(process.env.EMAILVERIFY_API_KEY);

export default async function handler(req, res) {
  // Shopify Webhook の署名を検証
  if (!verifyShopifyWebhook(req)) {
    return res.status(401).json({ error: 'Invalid signature' });
  }

  const order = req.body;
  const email = order.email;

  if (!email) {
    return res.status(200).json({ message: 'No email to verify' });
  }

  // メールを検証
  const result = await bv.verify({ email });

  // 検証結果を保存
  await saveVerificationResult(order.id, email, result);

  // リスクのある注文を処理
  if (result.status === 'invalid' || result.result.disposable) {
    await flagOrderForReview(order.id, {
      reason: 'email_verification_failed',
      status: result.status,
      disposable: result.result.disposable,
    });
  }

  res.status(200).json({ success: true });
}

function verifyShopifyWebhook(req) {
  const hmac = req.headers['x-shopify-hmac-sha256'];
  const body = JSON.stringify(req.body);
  const hash = crypto
    .createHmac('sha256', process.env.SHOPIFY_WEBHOOK_SECRET)
    .update(body, 'utf8')
    .digest('base64');

  return hmac === hash;
}

Webhook の登録

// Shopify Admin API を使用して Webhook を登録
const webhook = await shopify.webhooks.create({
  address: 'https://yourapp.com/api/webhooks/shopify/orders-create',
  topic: 'orders/create',
  format: 'json',
});

顧客メタフィールドの設定

検証結果を保存するメタフィールドを定義:

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

顧客セグメントの作成

検証結果に基づいてセグメントを作成:

有効なメールの顧客

customer_tag = 'email_verified'

リスクのある顧客

customer_tag = 'email_invalid' OR customer_tag = 'email_disposable'

ベストプラクティス

1. API エラー時はチェックアウトをブロックしない

try {
  const result = await bv.verify({ email });
  // 結果を処理
} catch (error) {
  console.error('検証に失敗:', error);
  // エラー時はチェックアウトを続行
}

2. 結果をキャッシュ

// Redis や Shopify メタフィールドを使用してキャッシュ
const cacheKey = `bv_${email}`;
const cached = await redis.get(cacheKey);

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

const result = await bv.verify({ email });
await redis.set(cacheKey, JSON.stringify(result), 'EX', 86400);

return result;

3. 分析用にトラッキング

// 検証結果をトラッキング
await analytics.track('email_verification', {
  order_id: order.id,
  status: result.status,
  score: result.score,
  disposable: result.result.disposable,
});

関連リソース

On this page