Contact Tracking
Identify contacts for personalized support and conversation continuity
Contact tracking lets you identify visitors so Goldilocks can provide personalized support and maintain conversation history across sessions.
Why Track Contacts?
Without identification, each visit is anonymous:
- No conversation history
- No personalization
- No memory of preferences
- Each session starts fresh
With identification:
- Conversations persist across sessions
- Contact memory is applied
- Personalized responses
- Better analytics
Basic Identification
Using Settings
Pass contact ID when loading the widget:
window.goldilocksSettings = {
apiKey: 'your-key',
customerId: 'cust_12345',
customerLabel: 'John Smith'
};Minimum Required
At minimum, provide customerId:
window.goldilocksSettings = {
apiKey: 'your-key',
customerId: 'your-unique-id'
};Contact Properties
Available Fields
| Field | Type | Description |
|---|---|---|
customerId | string | Unique identifier (required for tracking) |
customerLabel | string | Display name |
customerEmail | string | Email address |
customerData | object | Additional attributes |
Example with All Fields
window.goldilocksSettings = {
apiKey: 'your-key',
customerId: 'cust_12345',
customerLabel: 'John Smith',
customerEmail: 'john@example.com',
customerData: {
plan: 'pro',
company: 'Acme Corp',
signupDate: '2023-01-15',
totalOrders: 12,
lastPurchase: '2024-01-10'
}
};Dynamic Identification
After Page Load
If contact logs in after widget loads:
// User logs in
function onUserLogin(user) {
Goldilocks.setCustomer({
id: user.id,
label: user.name,
email: user.email
});
}Contact Logout
When user logs out:
function onUserLogout() {
Goldilocks.clearCustomer();
}Platform Examples
Shopify
<script>
window.goldilocksSettings = {
apiKey: 'your-key',
{% if customer %}
customerId: '{{ customer.id }}',
customerLabel: '{{ customer.name }}',
customerEmail: '{{ customer.email }}',
customerData: {
ordersCount: {{ customer.orders_count }},
totalSpent: '{{ customer.total_spent }}',
tags: {{ customer.tags | json }}
}
{% endif %}
};
</script>WordPress / WooCommerce
<script>
window.goldilocksSettings = {
apiKey: 'your-key',
<?php if (is_user_logged_in()):
$user = wp_get_current_user();
?>
customerId: '<?php echo $user->ID; ?>',
customerLabel: '<?php echo esc_js($user->display_name); ?>',
customerEmail: '<?php echo esc_js($user->user_email); ?>'
<?php endif; ?>
};
</script>React with Auth
function App() {
const { user, isAuthenticated } = useAuth();
useEffect(() => {
if (window.Goldilocks) {
if (isAuthenticated && user) {
Goldilocks.setCustomer({
id: user.id,
label: user.name,
email: user.email
});
} else {
Goldilocks.clearCustomer();
}
}
}, [isAuthenticated, user]);
return <div>Your app</div>;
}Using JWT/Session
// Get contact from your session
fetch('/api/current-user')
.then(res => res.json())
.then(user => {
if (user) {
window.goldilocksSettings = {
apiKey: 'your-key',
customerId: user.id,
customerLabel: user.name,
customerEmail: user.email
};
}
loadGoldilocksScript();
});Contact Data Best Practices
What to Include
Recommended:
- Unique identifier
- Name/label
- Account type/plan
- Relevant business data
Useful context:
- Order count
- Subscription status
- Account age
- Recent activity
What to Avoid
- Passwords or credentials
- Full credit card numbers
- Sensitive personal data
- Extremely large data sets
Data Limits
customerId: 256 characters maxcustomerLabel: 256 characters maxcustomerEmail: Standard email lengthcustomerData: 10KB max (JSON)
Using Contact Data
In Conversations
Contact data is available to the AI:
- Personalize greetings
- Reference order history
- Understand account context
- Provide relevant help
In Memory
Combined with contact memory:
- Remembered preferences
- Previous conversation context
- Extracted information from past chats
In Analytics
Track metrics by contact:
- Conversation history
- Resolution rates
- Topic patterns
Anonymous Visitors
For non-logged-in visitors:
Option 1: Anonymous (Default)
Don't set customerId. Each session is independent.
Option 2: Local Storage ID
Generate and persist a local ID:
let visitorId = localStorage.getItem('goldilocks_visitor');
if (!visitorId) {
visitorId = 'visitor_' + Math.random().toString(36).substr(2, 9);
localStorage.setItem('goldilocks_visitor', visitorId);
}
window.goldilocksSettings = {
apiKey: 'your-key',
customerId: visitorId,
customerLabel: 'Visitor'
};This maintains conversation continuity without login.
Option 3: Convert on Login
Start anonymous, convert when they log in:
// Initially anonymous
window.goldilocksSettings = { apiKey: 'your-key' };
// On login
Goldilocks.setCustomer({
id: user.id,
label: user.name
});
// Future conversations linked to this IDPrivacy Considerations
User Consent
- Inform users about tracking
- Comply with GDPR/CCPA if applicable
- Provide opt-out if required
Data Access
Contacts can:
- Request their data
- Request deletion
- View conversation history
See Security Settings for data management.
Troubleshooting
Contact Not Recognized
- Verify
customerIdis set - Check it's set before widget loads
- Verify ID is consistent across sessions
Data Not Showing
- Check
customerDataformat (valid JSON) - Verify size is under limit
- Check browser console for errors
History Not Persisting
- Confirm same
customerIdused - Check widget is identifying correctly
- Verify no
clearCustomer()calls