$npx -y skills add 40RTY-ai/shopify-admin-skills --skill shopify-admin-marketing-consent-reportRead-only: audits email and SMS marketing consent status across the customer base for compliance and segmentation.
| 1 | ## Purpose |
| 2 | Scans all customer records and reports the breakdown of email and SMS marketing consent status (subscribed, unsubscribed, pending, never asked). Used for compliance audits, GDPR/CAN-SPAM reviews, and understanding the addressable marketing audience. Read-only — no mutations. |
| 3 | |
| 4 | ## Prerequisites |
| 5 | - Authenticated Shopify CLI session: `shopify store auth --store <domain> --scopes read_customers` |
| 6 | - API scopes: `read_customers` |
| 7 | |
| 8 | ## Parameters |
| 9 | |
| 10 | | Parameter | Type | Required | Default | Description | |
| 11 | |-----------|------|----------|---------|-------------| |
| 12 | | store | string | yes | — | Store domain (e.g., mystore.myshopify.com) | |
| 13 | | channel | string | no | both | Consent channel to audit: `email`, `sms`, or `both` | |
| 14 | | format | string | no | human | Output format: `human` or `json` | |
| 15 | |
| 16 | ## Safety |
| 17 | |
| 18 | > ℹ️ Read-only skill — no mutations are executed. Safe to run at any time. |
| 19 | |
| 20 | ## Workflow Steps |
| 21 | |
| 22 | 1. **OPERATION:** `customers` — query |
| 23 | **Inputs:** `first: 250`, select `emailMarketingConsent { marketingState, consentUpdatedAt }`, `smsMarketingConsent { marketingState, consentUpdatedAt }`, pagination cursor |
| 24 | **Expected output:** All customers with consent states; paginate until `hasNextPage: false` |
| 25 | |
| 26 | 2. Count customers by consent state for each channel |
| 27 | |
| 28 | 3. Calculate: addressable audience (subscribed), at-risk (pending), unreachable (unsubscribed/not asked) |
| 29 | |
| 30 | ## GraphQL Operations |
| 31 | |
| 32 | ```graphql |
| 33 | # customers:query — validated against api_version 2025-01 |
| 34 | query MarketingConsentAudit($after: String) { |
| 35 | customers(first: 250, after: $after) { |
| 36 | edges { |
| 37 | node { |
| 38 | id |
| 39 | displayName |
| 40 | defaultEmailAddress { |
| 41 | emailAddress |
| 42 | } |
| 43 | emailMarketingConsent { |
| 44 | marketingState |
| 45 | consentUpdatedAt |
| 46 | marketingOptInLevel |
| 47 | } |
| 48 | smsMarketingConsent { |
| 49 | marketingState |
| 50 | consentUpdatedAt |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | pageInfo { |
| 55 | hasNextPage |
| 56 | endCursor |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | ``` |
| 61 | |
| 62 | ## Session Tracking |
| 63 | |
| 64 | **Claude MUST emit the following output at each stage. This is mandatory.** |
| 65 | |
| 66 | **On start**, emit: |
| 67 | ``` |
| 68 | ╔══════════════════════════════════════════════╗ |
| 69 | ║ SKILL: Marketing Consent Report ║ |
| 70 | ║ Store: <store domain> ║ |
| 71 | ║ Started: <YYYY-MM-DD HH:MM UTC> ║ |
| 72 | ╚══════════════════════════════════════════════╝ |
| 73 | ``` |
| 74 | |
| 75 | **After each step**, emit: |
| 76 | ``` |
| 77 | [N/TOTAL] <QUERY|MUTATION> <OperationName> |
| 78 | → Params: <brief summary of key inputs> |
| 79 | → Result: <count or outcome> |
| 80 | ``` |
| 81 | |
| 82 | **On completion**, emit: |
| 83 | |
| 84 | For `format: human` (default): |
| 85 | ``` |
| 86 | ══════════════════════════════════════════════ |
| 87 | MARKETING CONSENT REPORT |
| 88 | Total customers: <n> |
| 89 | |
| 90 | Email Marketing: |
| 91 | Subscribed: <n> (<pct>%) ← addressable |
| 92 | Unsubscribed: <n> (<pct>%) |
| 93 | Pending: <n> (<pct>%) |
| 94 | Not asked: <n> (<pct>%) |
| 95 | |
| 96 | SMS Marketing: |
| 97 | Subscribed: <n> (<pct>%) |
| 98 | Unsubscribed: <n> (<pct>%) |
| 99 | Not asked: <n> (<pct>%) |
| 100 | Output: consent_audit_<date>.csv |
| 101 | ══════════════════════════════════════════════ |
| 102 | ``` |
| 103 | |
| 104 | For `format: json`, emit: |
| 105 | ```json |
| 106 | { |
| 107 | "skill": "marketing-consent-report", |
| 108 | "store": "<domain>", |
| 109 | "total_customers": 0, |
| 110 | "email": { "subscribed": 0, "unsubscribed": 0, "pending": 0, "not_asked": 0 }, |
| 111 | "sms": { "subscribed": 0, "unsubscribed": 0, "not_asked": 0 }, |
| 112 | "output_file": "consent_audit_<date>.csv" |
| 113 | } |
| 114 | ``` |
| 115 | |
| 116 | ## Output Format |
| 117 | CSV file `consent_audit_<YYYY-MM-DD>.csv` with columns: |
| 118 | `customer_id`, `email`, `email_marketing_state`, `email_consent_updated_at`, `sms_marketing_state`, `sms_consent_updated_at` |
| 119 | |
| 120 | ## Error Handling |
| 121 | | Error | Cause | Recovery | |
| 122 | |-------|-------|----------| |
| 123 | | `THROTTLED` | API rate limit exceeded | Wait 2 seconds, retry up to 3 times | |
| 124 | | No customers | Empty store | Exit with 0 results | |
| 125 | |
| 126 | ## Best Practices |
| 127 | - "Subscribed" is your addressable marketing audience — a low subscription rate may indicate checkout opt-in is not prominent enough. |
| 128 | - "Pending" means a customer provided their email but has not confirmed consent — this is common for double opt-in flows. |
| 129 | - Run before major campaigns to get an accurate count of the addressable audience; your ESP will show a different number if it has additional unsubscribes not synced back to Shopify. |
| 130 | - GDPR compliance note: customers in the EU with `marketingOptInLevel: SINGLE_OPT_IN` may require a re-consent campaign depending on your legal basis for processing. |