Kentico Analytics Integrations: Setup Guide | OpsBlu Docs

Kentico Analytics Integrations: Setup Guide

Complete guide to integrating analytics and marketing tools with Kentico Xperience including Google Analytics, GTM, and Meta Pixel

This guide covers how to integrate analytics and marketing tools with Kentico Xperience, a .NET-based enterprise digital experience platform (DXP).

Available Integration Guides

Google Analytics 4 (GA4)

Google Tag Manager (GTM)

Meta Pixel

Kentico Development Models

Kentico supports multiple development approaches that affect how you implement tracking:

MVC Development Model (Kentico 12+)

The modern approach using ASP.NET MVC pattern:

  • Separate presentation and business logic
  • Use controllers and views for rendering
  • Implement tracking in layout files or partial views
  • Better performance and testability

Portal Engine (Legacy)

The original drag-and-drop development model:

  • Web Parts and widgets for page building
  • Master pages for templates
  • Web Part zones for content placement
  • Macro expressions for dynamic content

Page Builder (Kentico 13+)

Modern content editing experience:

  • Drag-and-drop page composition
  • Widgets for reusable components
  • Section-based layouts
  • Inline editing capabilities

Common Integration Points

Master Page / Layout Files

The primary location for global tracking code:

  • MVC: ~/Views/Shared/_Layout.cshtml
  • Portal Engine: Master page templates
  • Add tracking code in <head> or before </body>

Web Analytics Module

Kentico's built-in analytics system:

Custom Modules and Web Parts

For advanced implementations:

  • Create custom modules for tracking logic
  • Build reusable Web Parts for consent management
  • Implement server-side tracking when needed

Integration Considerations

Content Staging

  • Test tracking on staging before production deployment
  • Use macro conditions to exclude tracking on staging: {% raw %}{% CurrentSite.SiteName == "ProductionSite" %}{% endraw %}

Multi-Site Management

  • Configure tracking per site
  • Use site-specific settings for tracking IDs
  • Implement site-aware data layer variables

Performance Optimization

  • Load scripts asynchronously when possible
  • Use Kentico's output caching
  • Minimize impact on Core Web Vitals
  • Consider using Tag Manager for better control
  • Integrate with Kentico's cookie consent features
  • Implement GDPR-compliant tracking
  • Use OneTrust or Cookiebot for consent management
  • Conditionally load tracking based on consent

Macro Expressions

Kentico macro expressions allow dynamic content in templates:

// Get current page name
{% raw %}{% CurrentDocument.DocumentName %}{% endraw %}

// Get site name
{% raw %}{% CurrentSite.SiteName %}{% endraw %}

// Conditional rendering
{% raw %}{% if(CurrentSite.SiteName == "ProductionSite") { "<!-- Production -->" } %}{% endraw %}

// User information
{% raw %}{% CurrentUser.Email %}{% endraw %}

Best Practices

  1. Use Layout Files for Global Code - Add tracking scripts to master pages or layout files for site-wide implementation

  2. Leverage Kentico Settings - Store tracking IDs and configuration in Kentico settings for easy management

  3. Test in Staging - Always test implementations in staging environment before deploying to production

  4. Document Customizations - Keep records of custom code and integration points for future developers

  5. Monitor Performance - Track Core Web Vitals and optimize script loading

  6. Implement Consent Management - Ensure compliance with privacy regulations

  7. Use GTM When Possible - Google Tag Manager provides flexibility without code deployments

Next Steps

Choose an integration guide based on your needs:

For issues, see the Troubleshooting Guide.