Merge Profiles | vendrux Docs

Written by

in

,

The nativeFunctions.klaviyoMergeProfiles() function allows you to merge user profiles across mobile app and website platforms in Klaviyo. This function should only be called in Canvas-based environments.

External User ID Usage

// Check if the user agent contains 'canvas' (case-insensitive)
if (navigator.userAgent.toLowerCase().includes('canvas')) {
  try {
    // Merge profile using external ID
    nativeFunctions.klaviyoMergeProfiles('user123', null)
  } catch (error) {
    // Handle any potential errors
    console.error('Profile merge failed:', error)
  }
}

Email Usage

// Check if the user agent contains 'canvas' (case-insensitive)
if (navigator.userAgent.toLowerCase().includes('canvas')) {
  try {
    // Merge profile using email
    nativeFunctions.klaviyoMergeProfiles(null, 'user@example.com')
  } catch (error) {
    // Handle any potential errors
    console.error('Profile merge failed:', error)
  }
}

Profile Merge Mechanism

User Existence Verification

The klaviyoMergeProfiles() function performs an internal check to determine the user’s existence in Klaviyo before initiating the merge process. This means:

  • The merge is only triggered if a matching user profile is found
  • If no existing user is detected, no merge action occurs
  • This ensures data integrity and prevents unnecessary profile modifications

Post-Merge User Information Update

After a successful profile merge, the app automatically updates the external user ID in the userInfo object. This process ensures:

  • The most recent and accurate user identification
  • Synchronization between the app’s internal user tracking and Klaviyo’s profile system
  • Consistent user data across different platforms and touchpoints

More details can be found here: https://www.vendrux.com/docs/get-user-information

Why the User Agent Check?

  • Ensures the function is only called in the intended Vendrux based environment
  • Prevents errors in non-supported platforms
  • Provides a safeguard against unintended function calls

Function Signature

nativeFunctions.klaviyoMergeProfiles(externalID, email)

Parameters

  • externalID (Optional): A unique identifier for the user
  • email (Optional): The user’s email address

Important Notes

  • You must provide at least one of the two parameters
  • Do not pass both externalID and email simultaneously
  • The function will only execute if the user agent contains “canvas”

Best Practices

  • Always wrap nativeFunctions.klaviyoMergeProfiles() in a user agent check
  • Use toLowerCase() to ensure case-insensitive matching
  • Implement robust error handling
  • Log merge operations for tracking

Potential Pitfalls to Avoid

  • Calling the function without a user agent check
  • Passing both parameters simultaneously
  • Ignoring potential merge errors

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *