Documentation

Visitor Profiles

Add custom properties to visitor records

Overview

Loamly automatically captures visitor information like traffic source, location, and device. Visitor profiles let you add your own properties to enrich these records with business context:

  • Company name and size
  • User type (prospect, trial, customer)
  • Plan or subscription tier
  • Industry or vertical
  • Lead score or qualification status
  • Any custom property relevant to your business

Setting properties

Use the window.loamly.set() method to add properties to the current visitor:

window.loamly.set({
  company: 'Acme Corp',
  company_size: '50-200',
  industry: 'SaaS'
});

Properties are merged with the visitor record. You can call set() multiple times and properties will accumulate:

// First call
window.loamly.set({ company: 'Acme Corp' });

// Later call adds more properties
window.loamly.set({ plan: 'enterprise', mrr: 999 });

// Result: visitor has company, plan, and mrr properties

Property types

TypeExampleNotes
Stringcompany: "Acme Corp"Max 255 characters
Numberemployee_count: 150Integer or decimal
Booleanis_enterprise: truetrue or false
Datesignup_date: "2024-12-01"ISO 8601 string

Arrays and objects

Nested objects and arrays are not supported. Flatten complex data structures into individual properties.

Reserved property names

These names are reserved and cannot be used:

  • id, visitor_id
  • email (use identify() instead)
  • source, referrer
  • first_seen, last_seen

Identifying visitors

To associate a visitor with an email address, use the identify() method:

// When user logs in or submits a form
window.loamly.identify('user@example.com');

// Optionally include additional properties
window.loamly.identify('user@example.com', {
  name: 'Jane Smith',
  company: 'Acme Corp',
  plan: 'pro'
});

Once identified, the visitor record is linked to that email. This enables:

  • Matching with Stripe payments for revenue attribution
  • Cross-device tracking when the user logs in elsewhere
  • Integration with your CRM or email tools

Automatic form capture

Loamly automatically captures emails from form submissions. You only need to call identify() manually for non-form scenarios like login events.

Common use cases

After login

// In your login success handler
async function onLoginSuccess(user) {
  window.loamly?.identify(user.email, {
    user_id: user.id,
    name: user.name,
    plan: user.subscription?.plan,
    company: user.company?.name
  });
}

From enrichment service

// After enriching lead data (e.g., from Clearbit)
function enrichVisitor(enrichmentData) {
  window.loamly?.set({
    company: enrichmentData.company.name,
    company_size: enrichmentData.company.employees,
    industry: enrichmentData.company.industry,
    company_revenue: enrichmentData.company.revenue,
    linkedin_url: enrichmentData.person.linkedIn
  });
}

From your backend

If you have user data server-side, pass it to the frontend after authentication:

// Server: Include user data in your page
const userData = {
  email: user.email,
  company: user.company,
  plan: user.plan,
  signupDate: user.created_at
};

// Client: Set properties on page load
<script>
  window.loamly?.identify(userData.email, {
    company: userData.company,
    plan: userData.plan,
    signup_date: userData.signupDate
  });
</script>

Lead scoring integration

// When lead score updates
function onLeadScoreChange(visitorId, newScore, qualification) {
  window.loamly?.set({
    lead_score: newScore,
    lead_status: qualification, // 'cold', 'warm', 'hot', 'qualified'
    score_updated_at: new Date().toISOString()
  });
}