How to Identify Contacts who Click Through Emails to Your Site from Email Sequencers

With the right setup, Rep.ai can identify contacts (name, company, email) who click through email campaigns.

Email clickthrough identification at contact-level relies on a unique link query parameters per email recipient. Below is a set of steps to configure your Rep.ai instance to recognize individuals by their email.

  1. Add this code to your site in addition to the installation code you already installed:

<script>
  function runAfterDomLoaded(callback) {
    if (document.readyState === 'loading') {
      document.addEventListener('DOMContentLoaded', callback);
    } else {
      callback();
    }
  }

  function decodeQueryParam(param) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
      var pair = vars[i].split("=");
      if (pair[0] === param) {
        return pair[1] ? atob(pair[1]) : null;
      }
    }
    return null;
  }

  function onDomReady() {
    var email = decodeQueryParam("sbec");
    var firstName = decodeQueryParam("sbfn");
    var lastName = decodeQueryParam("sbln");
    var companyName = decodeQueryParam("sbcn");
    
    var displayName = [firstName, lastName].filter(function(item) {
      return !!item;
    }).join(" ") || email;

    if (email) {
      // Set up identification object with mandatory email and any other available information
      var identifyObj = { email: email, displayName: displayName };
      if (companyName) identifyObj.company = companyName;

      // Identify the user with the provided details
      RepAI("identify", email, identifyObj);

      // Create an alert title
      var alertTitle = 'Email-click through from ' + displayName;
      
      // Initiate alert with included details
      var alertBody = "";
      if (displayName !== email) alertBody += "Name: " + displayName + " ";
      if (companyName) alertBody += "Company: " + companyName;

      RepAI("alert", { title: alertTitle, body: alertBody.trim() });
    } else if (!email) {
      console.log("Mandatory query parameter 'sbec' (email) not found.");
    }
  }

  runAfterDomLoaded(onDomReady);
</script>

  1. Build a reference table of email and base64-encoded query parameters attached to the clickthrough URL. This can be done in a Google Sheet, but is easiest to automate in Clay, especially if you use a sequencer that integrates with Clay.

    1. The one column you must encode is the email as “sbec”

    2. You can optionally encode firstname as “sbfn”, lastname as “sbln”, and company name as “sbcn”

  2. Integrate the table from Clay or Sheets into your campaign, so that the hyperlinked text includes the encoded data.

  3. Rep.ai will pick up the clickthrough and display alerts and contact information accordingly.

For reference, below is the Python code to encode an email. You can build this as a column in Clay.

import base64

# String to encode
data = "[email protected]"

# Encode the string to bytes
encoded_bytes = base64.b64encode(data.encode('utf-8'))

# Convert bytes to string
encoded_string = encoded_bytes.decode('utf-8')

print(encoded_string)

Last updated