Data Layer Overview
Crazy Egg uses visual tracking primarily, but you can enhance data collection with user segments and custom variables.
User Identification
Setting User Variables
// Set user-level data
if (typeof CE2 !== 'undefined') {
CE2.set('user_id', 'user123');
CE2.set('plan', 'premium');
}
Segment by User Type
function setUserSegment(userData) {
if (typeof CE2 !== 'undefined') {
CE2.set('user_type', userData.type);
CE2.set('subscription', userData.plan);
}
}
Page-Level Data
Custom Page Variables
// Set page context
CE2.set('page_category', 'product');
CE2.set('page_section', 'electronics');
Dynamic Content
// For dynamic pages
CE2.set('product_id', productId);
CE2.set('price_range', getPriceRange());
Filtering and Segmentation
Using Variables in Reports
After setting variables:
Common Segments
- Logged in vs anonymous
- Paid vs free users
- New vs returning visitors
- Traffic source segments