Clicky Data Layer Setup | Blue Frog Docs

Clicky Data Layer Setup

Pass custom data and visitor information to Clicky analytics for enhanced tracking and segmentation.

Data Layer Overview

Clicky's data layer capabilities allow you to pass custom information about visitors and sessions. This enables richer segmentation and more meaningful analytics.

 


 

Custom Session Data

Setting Custom Data

Pass custom key-value pairs with your tracking:

var clicky_custom = clicky_custom || {};
clicky_custom.session = {
  user_type: 'premium',
  account_age: '6_months',
  plan: 'enterprise'
};

This data appears in visitor profiles and can be used for filtering.

Dynamic Data Assignment

Set data based on user state:

var clicky_custom = clicky_custom || {};
clicky_custom.session = {};

// From your application
if (userLoggedIn) {
  clicky_custom.session.logged_in = 'yes';
  clicky_custom.session.user_id = userId;
  clicky_custom.session.subscription = userPlan;
}

if (cartItems > 0) {
  clicky_custom.session.cart_value = cartTotal;
  clicky_custom.session.cart_items = cartItems;
}

 


 

User Identification

Identifying Logged-In Users

Track known users across sessions:

var clicky_custom = clicky_custom || {};
clicky_custom.visitor = {
  username: 'john_doe',
  email: 'john@example.com'  // Optional
};

Privacy-Conscious Identification

Use non-PII identifiers:

var clicky_custom = clicky_custom || {};
clicky_custom.visitor = {
  username: 'user_' + hashedUserId  // Hashed/anonymized ID
};

 


 

E-commerce Data

Product Information

Pass product context:

var clicky_custom = clicky_custom || {};
clicky_custom.session = {
  product_category: 'Electronics',
  product_brand: 'TechBrand',
  product_price_range: '100-500'
};

Cart and Transaction Data

Track shopping behavior:

// On cart page
clicky_custom.session = {
  cart_value: 149.99,
  cart_items: 3,
  coupon_applied: 'yes'
};

// On purchase
clicky.goal('purchase', 149.99, 'Order Complete');

 


 

Configuration Options

Full Configuration Reference

<script>
  var clicky_site_ids = clicky_site_ids || [];
  clicky_site_ids.push(YOUR_SITE_ID);

  var clicky_custom = clicky_custom || {};

  // Visitor identification
  clicky_custom.visitor = {
    username: 'user_identifier'
  };

  // Session data
  clicky_custom.session = {
    custom_key: 'custom_value'
  };

  // Tracking behavior
  clicky_custom.cookies_disable = 0;      // 1 to disable cookies
  clicky_custom.dnt = 0;                  // 1 to respect DNT
  clicky_custom.history_disable = 0;      // 1 to disable HTML5 history
  clicky_custom.outbound_disable = 0;     // 1 to disable outbound tracking
  clicky_custom.outbound_pattern = null;  // Custom outbound pattern
  clicky_custom.timeout = 5;              // Engagement timeout (minutes)
</script>
<script async src="//static.getclicky.com/js"></script>

 


 

Dynamic Updates

Updating Data After Load

Modify session data during the visit:

// Update session data dynamically
if (typeof clicky_custom !== 'undefined') {
  clicky_custom.session = clicky_custom.session || {};
  clicky_custom.session.viewed_pricing = 'yes';
}

// Log the update with a custom page view
if (typeof clicky !== 'undefined') {
  clicky.log(window.location.pathname, document.title);
}

 


 

Best Practices

Data Structure

  • Use consistent naming conventions
  • Avoid PII unless necessary
  • Keep values simple (strings, numbers)
  • Limit the number of custom fields

Performance

  • Set clicky_custom before the script loads
  • Avoid large data objects
  • Don't update data on every interaction

Privacy

  • Hash or anonymize user identifiers
  • Don't store sensitive information
  • Respect user consent preferences
  • Document what data you collect
// SYS.FOOTER