Skip to main content
Custom customer authentication allows you to authenticate users with your own system instead of using Shopify accounts or Cevoid email authentication. This is useful for headless setups or stores running on platforms other than Shopify. The implementation involves encrypting a payload with a key provided by Cevoid and attaching the result to your widget embed code.
This implementation requires server-side code. The encryption key must never be exposed to the client or shared with anyone.

How it works

  1. You retrieve user information from your authenticated session
  2. You create an encrypted digest on the server using the user’s ID and email
  3. You pass the digest and user info to the Cevoid widget div code
  4. Cevoid verifies the digest and authenticates the user

Set up custom customer authentication

Step 1: Enable custom customer authentication

  1. Navigate to Settings -> Rewards program -> General
  2. Under Access and enrollment, set Authentication to Custom customer authentication
  3. Copy your encryption key and tracking ID from this page

Step 2: Get your widget embed code

  1. Navigate to Rewards program -> On-site widgets
  2. Select the widget you want to embed
  3. Click Embed in the top right corner
  4. Copy the div code
The base embed code looks like this:
<div 
  class="cevoid-widget" 
  data-id="ew-3qGflV" 
  data-tracking-id="cv-1234-1"
></div>

Step 3: Add user information to the embed code

Add the following data attributes with your authenticated user’s information:
AttributeRequiredDescription
data-user-emailYesThe user’s email address
data-user-idYesThe user’s ID in your system
data-user-nameNoThe user’s display name
<div
  class="cevoid-widget"
  data-id="ew-3qGflV"
  data-tracking-id="cv-1234-1"
  data-user-email="{{ EMAIL }}"
  data-user-id="{{ EXTERNAL_USER_ID }}"
  data-user-name="{{ NAME }}"
></div>

Step 4: Create the digest

The digest authenticates the user and must be generated server-side. Payload format: {{ USER_ID }},{{ EMAIL }} For example, for a user with ID 1234 and email [email protected], the payload is: Encryption method: HMAC with SHA256 algorithm, signed with your encryption key. Node.js example:
const crypto = require('crypto');

const encryptionKey = 'YOUR_ENCRYPTION_KEY';
const userId = '1234';
const email = '[email protected]';

const digest = crypto
  .createHmac('sha256', encryptionKey)
  .update(`${userId},${email}`)
  .digest('hex');

Step 5: Add the digest to the embed code

Add the generated digest as data-digest:
<div
  class="cevoid-widget"
  data-id="ew-3qGflV"
  data-tracking-id="cv-1234-1"
  data-digest="{{ DIGEST }}"
  data-user-email="{{ EMAIL }}"
  data-user-id="{{ EXTERNAL_USER_ID }}"
  data-user-name="{{ NAME }}"
></div>

Complete example

For a user with: The final embed code would look like:
<div
  class="cevoid-widget"
  data-id="ew-3qGflV"
  data-tracking-id="cv-1234-1"
  data-digest="a1b2c3d4e5f6..."
  data-user-email="[email protected]"
  data-user-id="1234"
  data-user-name="Viktor"
></div>