Help

Klaviyo Integration Guide

Last updated: January 2026


1. Setting up Klaviyo for your store with CodeRally

Prerequisites

  • Active Klaviyo account
  • CodeRally app installed in your Shopify store
  • Admin access to both Shopify and Klaviyo

Step 1: Connect Klaviyo to CodeRally

  1. Navigate to Settings
    • Open your Shopify Admin
    • Go to Apps → CodeRally
    • Click on "Settings" in the left navigation menu
    Navigate to Settings Screenshot
  2. Initiate Klaviyo Connection
    • In the Integrations section, locate the "Klaviyo Integration" card
    • Click the "Connect Klaviyo" button
    • You'll be redirected to Klaviyo's OAuth authorization page
    Initiate Klaviyo Connection Screenshot
  3. Partner Review Notice

    Klaviyo may display a notice stating that the CodeRally app has not yet been reviewed by Klaviyo's partner team.

    ⚠️ Important Note

    CodeRally is safe to authorize. The "not reviewed" message simply means the app is still in Klaviyo's review queue. CodeRally only requests the minimum permissions required to sync customer profiles and events, and it does not access sensitive data such as billing information or credentials.

  4. Review Permissions

    Review the requested permissions carefully. These typically include:

    • Writing customer profiles and events
    • Creating or updating lists and segments

    Once reviewed, click Continue.

  5. Authorize CodeRally
    • Review the requested permissions:
      • accounts:read - Read account information
      • campaigns:read - Read campaign data
      • profiles:read - Read customer profile data
      • events:write - Send discount eligibility events
    • Click "Allow" to grant CodeRally access to your Klaviyo account
    Authorize CodeRally Screenshot
  6. Confirmation
    • You'll be redirected back to CodeRally
    • The Klaviyo Integration card will display a green "Connected" badge
    • CodeRally will begin syncing data automatically
    Confirmation Screenshot

Security Notes:

  • CodeRally uses OAuth 2.0 with PKCE (Proof Key for Code Exchange) for secure authentication
  • Your Klaviyo API credentials are encrypted and stored securely
  • Access tokens are automatically refreshed before expiration
  • You can disconnect at any time from the Settings page

Step 2: Create Your Klaviyo Flow

  1. Create a New Flow in Klaviyo
    • Go to Klaviyo Dashboard → Flows
    • Click "Create Flow"
    • Choose "Create from Scratch"
  2. Set the Trigger
    • Trigger Type: Metric
    • Metric Name: Eligible for Discount
    • Flow Name: "Abandoned Cart - Discount Recovery"
  3. Configure the Flow
    [Trigger]
    When someone "Eligible for Discount"
     ↓
    [Email #1]
    Email #1 Subject
    Status: Live
    Delay: Day 0 (send immediately)
     ↓
    [End]

    Visual Reference (as shown in your screenshot):

    • Trigger: Lightning bolt icon with "When someone Eligible for Discount"
    • Email: Envelope icon with your subject line
    • Delay: "Day 0" (immediate)
    • Status: "Live" (green indicator)
  4. Email Configuration
    • Subject Line: Customize your subject (e.g., "Your Special Discount Awaits! 🎁")
    • Sender Name: Your store name
    • Sender Email: Your support/marketing email
    • Preview Text: Craft compelling preview text
  5. Activate the Flow
    • Set status to "Live"
    • Test with a sample event before going live

Step 3: Add Your Email Template

Copy and paste this template into your Klaviyo email editor (use the HTML mode):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">  
<head>    
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title>
  Your Special Discount
</title>
</head>
<body style="margin:0; padding:0; background-color:#f4f4f4;">    
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse:collapse;" width="100%">      
  <tr>        
    <td align="center" style="padding:20px 0;">          <!-- 600px main container -->
      <table border="0" cellpadding="0" cellspacing="0" style="border-collapse:collapse; background-color:#ffffff;" width="600">            <!-- Header -->
        <tr>              
          <td align="center" bgcolor="#ffffff" style="padding:40px 20px 30px 20px;">                
            <h1 style="margin:0; font-family:Arial, sans-serif; font-size:24px; line-height:30px; color:#333333; font-weight:bold;">
              Your special offer is here!
            </h1>
          </td>
        </tr>
<!-- Body -->
        <tr>              
          <td bgcolor="#ffffff" style="padding:0 30px 40px 30px; font-family:Arial, sans-serif; font-size:15px; line-height:22px; color:#555555;">                
            <p style="margin:0 0 15px 0;">
              Hi there,
            </p>
            {% if event.discount_value_type == "discount_code" %}
            <p style="margin:0 0 15px 0;">
              Thank you for being a valued customer!
                We’ve created a special discount just for you.
                Use the code below at checkout to receive
              <strong>{{ event.discount_amount }}% off</strong> your purchase.
            </p>
            {% else %}
            <p style="margin:0 0 15px 0;">
              Thank you for being a valued customer!
                We’ve created a special discount just for you.
                Enjoy
              <strong>{{ event.discount_amount }}% off</strong> —
                the discount will be
              <strong>automatically applied once you add eligible products to your cart</strong>.
            </p>
            {% endif %}
            {% if event.discount_value_type == "discount_code" %}
<!-- Discount Code Block -->
            <table align="center" border="0" cellpadding="0" cellspacing="0" style="margin:20px auto; border-collapse:collapse; text-align:center;">                  
              <tr>                    
                <td align="center" bgcolor="#eeeeee" style="padding:15px 25px; border-radius:5px; font-family:Arial, sans-serif; font-size:18px; line-height:22px; color:#333333; font-weight:bold;">
                  {{ event.discount_code }}
                </td>
              </tr>
            </table>
            {% endif %}
            <p style="margin:20px 0 10px 0;">
              This discount is only applicable to the following product(s):
            </p>
<!-- Products Table -->
            <table border="0" cellpadding="10" cellspacing="0" style="border-collapse:collapse; margin-top:5px;" width="100%">                  
              <tr style="background-color:#f4f4f4;">                    
                <td style="font-family:Arial, sans-serif; font-size:14px; font-weight:bold; border-bottom:1px solid #dddddd;">
                  Product
                </td>
                <td style="font-family:Arial, sans-serif; font-size:14px; font-weight:bold; border-bottom:1px solid #dddddd;">
                  Price
                </td>
                <td style="font-family:Arial, sans-serif; font-size:14px; font-weight:bold; border-bottom:1px solid #dddddd;">
                  Quantity
                </td>
              </tr>
              {% for product in event.products %}
              <tr>                    
                <td style="font-family:Arial, sans-serif; font-size:14px; border-bottom:1px solid #eeeeee; padding:8px 10px;">
                  {{ product.title }}
                </td>
                <td style="font-family:Arial, sans-serif; font-size:14px; border-bottom:1px solid #eeeeee; padding:8px 10px;">
                  {{ product.price }} {{ event.currency }}
                </td>
                <td style="font-family:Arial, sans-serif; font-size:14px; border-bottom:1px solid #eeeeee; padding:8px 10px;">
                  {{ product.quantity }}
                </td>
              </tr>
              {% endfor %}
            </table>
            <p style="margin:20px 0 5px 0;">
              Minimum cart value to apply this discount:
              <strong>{{ event.cart_value }} {{ event.currency }}</strong>
            </p>
          </td>
        </tr>
<!-- Footer -->
        <tr>              
          <td align="center" bgcolor="#333333" style="padding:30px 30px 30px 30px;">                
            <p style="margin:0; font-family:Arial, sans-serif; font-size:14px; line-height:20px; color:#ffffff;">                  <a href="{{ organization.url|default:'#' }}" style="color:#ffffff; text-decoration:underline;">
                Visit our store
              </a>
            </p>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>

Klaviyo Variables Available

Variable Description Example
event.discount_code The discount code "SUMMER20"
event.discount_amount Discount percentage "20"
event.discount_value_type Type of discount "discount_code" or "automatic"
event.eligibility_type Match type "product", "collection", "store_wide"
event.products Array of products [{title, price, quantity}]
event.collections Array of collections [{title, collection_id}] (only for collection discounts)
event.cart_value Abandoned cart total "45.99"
event.currency Store currency "USD"

Customization Tips

  1. Replace Placeholder Links: Update {{ organization.url|default:'#' }} with your actual store URL
  2. Add Logo: Insert your store logo in the header section
  3. Brand Colors: Replace #333333, #eeeeee with your brand colors
  4. Call-to-Action Button: Add a "Shop Now" button linking back to the cart
  5. Urgency: Add time-limited messaging (e.g., "Offer expires in 24 hours")

2. How It Works

CodeRally monitors cart and checkout abandonment in Klaviyo. When a customer abandons their cart for 30+ minutes, CodeRally matches products in the cart against your active Shopify discount codes (product-specific, collection-wide, or store-wide). If a match is found, CodeRally sends an "Eligible for Discount" event to Klaviyo with the discount code, product details, and cart information. This triggers your Klaviyo flow, which automatically emails the customer with their personalized discount. Customers only receive each discount once per product to prevent spam.


3. Data Handling & Privacy

What Data CodeRally Receives

CodeRally syncs the following data from Klaviyo:

From Cart/Checkout Events:

  • Klaviyo Profile ID: Unique identifier for the customer in Klaviyo
  • Checkout/Cart ID: Shopify's checkout or cart session ID
  • Event Timestamp: When the cart/checkout was created
  • Line Items:
    • Product ID
    • Variant ID
    • Product title
    • Price
    • Quantity
  • Cart Total Value: Total amount in the cart
  • Currency: Store currency code

From Revenue Events:

  • Klaviyo Profile ID
  • Order ID: Shopify order identifier
  • Order Timestamp: When the order was placed

What Data CodeRally Sends to Klaviyo

When a discount match is found:

  • Event Type: "Eligible for Discount"
  • Profile ID: Links the event to the customer's Klaviyo profile
  • Discount Information: Code, value, type
  • Product Details: Titles, prices, quantities
  • Collection Details: Names and IDs (if applicable)

Privacy & Email Addresses

Important:

CodeRally does NOT store customer email addresses

  • Email addresses are managed entirely within Klaviyo
  • CodeRally only stores Klaviyo Profile IDs to link events
  • Email delivery is handled by Klaviyo using their own profile data
  • Customers' personal information remains in Klaviyo's secure infrastructure

Data Security

  • Encryption: All API keys and tokens are encrypted at rest
  • OAuth Tokens: Automatically refreshed and rotated for security
  • Minimal Storage: CodeRally only stores essential IDs and product data, not full event payloads (saves ~95% storage)
  • GDPR Compliant: No PII (Personally Identifiable Information) is stored by CodeRally

Data Retention

  • Abandoned Carts: Processed carts are retained for 30 days for retroactive discount matching
  • Discount Events Sent: Records are kept to prevent duplicate emails (deduplication)
  • Converted Carts: Marked as "converted" and excluded from future discount matching

Disconnecting

If you disconnect Klaviyo:

  • CodeRally will stop syncing events immediately
  • No new discount events will be sent to Klaviyo
  • Your existing Klaviyo flows and data remain intact
  • You can reconnect at any time without data loss

Support

For technical assistance:

Last Updated: January 2026
Version: 1.0

Subscribe

Ready to boost your Shopify store's performance?

Discover strategies and tools to increase sales, speed, and customer engagement.