TRACKING - Rastreamento Avançado de Comportamento
O que é este Node?
O TRACKING é o node responsável por rastreamento avançado e especializado de comportamentos como visualizações de página, cliques, submissões de formulário, conversões, jornadas e testes A/B.
Por que este Node existe?
Rastreamento especializado oferece insights profundos. O TRACKING existe para:
- Page views: Rastrear navegação e fluxo de páginas
- Click tracking: Mapear interações com elementos
- Form submissions: Analisar conversão de formulários
- Conversion tracking: Medir atingimento de objetivos
- User journey: Mapear jornada completa do usuário
- A/B testing: Rastrear experimentos e variantes
Como funciona internamente?
Quando o TRACKING é executado, o sistema:
- Identifica o trackingType (page_view, click, form_submission, etc.)
- Valida dados específicos do tipo de tracking
- Enriquece com contexto (userId, sessionId, deviceInfo)
- Adiciona timestamp se não fornecido
- Executa método especializado para o tipo
- Armazena evento no sistema de tracking
- Retorna confirmação com dados completos
Código interno (analytics-executor.service.ts:207-234):
private async executeTracking(parameters: any, context: any): Promise<any> {
const { trackingType, data, userId, sessionId, deviceInfo } = parameters;
this.logger.log(`🔍 TRACKING - Type: ${trackingType}`);
switch (trackingType?.toLowerCase()) {
case 'page_view':
return this.trackPageView(data, userId, sessionId, context);
case 'click':
return this.trackClick(data, userId, sessionId, context);
case 'form_submission':
return this.trackFormSubmission(data, userId, sessionId, context);
case 'conversion':
return this.trackConversion(data, userId, sessionId, context);
case 'user_journey':
return this.trackUserJourney(data, userId, sessionId, context);
case 'a_b_test':
return this.trackABTest(data, userId, sessionId, context);
default:
return this.trackGeneric(trackingType, data, userId, sessionId, context);
}
}
Quando você DEVE usar este Node?
Use TRACKING sempre que precisar rastrear comportamentos específicos:
Casos de uso:
- Análise de navegação: Rastrear pages/screens visitadas
- Heatmaps: Mapear cliques em elementos
- Form analytics: Medir conversão de formulários e campos abandonados
- Goal tracking: Rastrear atingimento de objetivos
- Journey mapping: Mapear fluxo completo do usuário
- Experimentos: Rastrear variantes de A/B tests
Quando NÃO usar TRACKING:
- Eventos de negócio genéricos: Use EVENT
- Métricas numéricas: Use METRIC
- Analytics com providers: Use ANALYTICS
Parâmetros Detalhados
trackingType (string, obrigatório)
O que é: Tipo de rastreamento especializado.
Opções:
- page_view - Visualização de página
- click - Clique em elemento
- form_submission - Submissão de formulário
- conversion - Conversão/objetivo atingido
- user_journey - Etapa da jornada
- a_b_test - Teste A/B
- Qualquer outro tipo customizado
Flow completo para testar tipos:
{
"name": "Teste TRACKING - Types",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "tracking_page",
"type": "tracking",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Page View",
"parameters": {
"trackingType": "page_view",
"data": {
"page": "home",
"title": "Home Page",
"url": "/home"
}
}
}
},
{
"id": "tracking_click",
"type": "tracking",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Click Tracking",
"parameters": {
"trackingType": "click",
"data": {
"element": "button",
"text": "Criar Conta",
"href": "/signup"
}
}
}
},
{
"id": "tracking_conversion",
"type": "tracking",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Conversion",
"parameters": {
"trackingType": "conversion",
"data": {
"goalId": "signup_goal",
"goalName": "User Signup",
"value": 100,
"currency": "BRL"
}
}
}
},
{
"id": "message_1",
"type": "message",
"position": { "x": 900, "y": 100 },
"data": {
"label": "Confirmar",
"parameters": {
"message": "✅ 3 tipos de tracking registrados:\n- Page view\n- Click\n- Conversion"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 1100, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "tracking_page" },
{ "source": "tracking_page", "target": "tracking_click" },
{ "source": "tracking_click", "target": "tracking_conversion" },
{ "source": "tracking_conversion", "target": "message_1" },
{ "source": "message_1", "target": "end_1" }
]
}
data (object, obrigatório)
O que é: Dados específicos do tipo de tracking.
Estrutura varia por trackingType:
page_view:
{
"page": "home", // Nome da página
"title": "Home Page", // Título
"url": "/home", // URL
"referrer": "/landing" // Página anterior
}
click:
{
"element": "button", // Tipo do elemento
"text": "Criar Conta", // Texto do elemento
"href": "/signup", // Link (se aplicável)
"position": { // Posição (opcional)
"x": 100,
"y": 200
}
}
form_submission:
{
"formId": "signup_form",
"formName": "User Signup",
"fields": { // Campos do formulário
"name": "João",
"email": "joao@example.com"
},
"success": true, // Sucesso?
"errors": [] // Erros (se houver)
}
conversion:
{
"goalId": "purchase_goal",
"goalName": "Purchase",
"value": 150.00, // Valor da conversão
"currency": "BRL",
"category": "ecommerce"
}
user_journey:
{
"step": 2,
"stepName": "Contact Info",
"funnel": "signup",
"previousStep": "Personal Info",
"nextStep": "Preferences",
"timeSpent": 45 // Segundos na etapa
}
a_b_test:
{
"experimentId": "exp_123",
"experimentName": "Button Color",
"variant": "red", // Variante exibida
"converted": true // Usuário converteu?
}
userId (string, opcional)
O que é: ID do usuário.
Padrão: Usa context.userId
sessionId (string, opcional)
O que é: ID da sessão.
Padrão: Usa context.sessionId
deviceInfo (object, opcional)
O que é: Informações do dispositivo.
Parâmetros
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| trackingType | string | Sim | Tipo de tracking (page_view, click, form_submission, conversion, user_journey, a_b_test) |
| data | object | Sim | Dados específicos do tipo de tracking |
| userId | string | Não | ID do usuário (padrão: context.userId) |
| sessionId | string | Não | ID da sessão (padrão: context.sessionId) |
| deviceInfo | object | Não | Informações do dispositivo |
Exemplo 1: User Journey Completo
Objetivo: Rastrear jornada completa com tempo em cada etapa
JSON para Importar
{
"name": "Complete User Journey",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "variable_step1_start",
"type": "variable",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Início Step 1",
"parameters": {
"operation": "set",
"variables": {
"step1_start": "{{$timestamp}}"
}
}
}
},
{
"id": "tracking_journey_1",
"type": "tracking",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Journey - Step 1 Iniciado",
"parameters": {
"trackingType": "user_journey",
"data": {
"step": 1,
"stepName": "Landing Page",
"funnel": "signup",
"nextStep": "Personal Info"
}
}
}
},
{
"id": "message_1",
"type": "message",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Boas-vindas",
"parameters": {
"message": "👋 Bem-vindo! Vamos começar?"
}
}
},
{
"id": "delay_1",
"type": "delay",
"position": { "x": 900, "y": 100 },
"data": {
"label": "Tempo na Landing",
"parameters": {
"duration": 3,
"unit": "seconds"
}
}
},
{
"id": "tracking_journey_1_complete",
"type": "tracking",
"position": { "x": 1100, "y": 100 },
"data": {
"label": "Journey - Step 1 Completo",
"parameters": {
"trackingType": "user_journey",
"data": {
"step": 1,
"stepName": "Landing Page",
"funnel": "signup",
"timeSpent": 3,
"nextStep": "Personal Info"
}
}
}
},
{
"id": "variable_step2_start",
"type": "variable",
"position": { "x": 1300, "y": 100 },
"data": {
"label": "Início Step 2",
"parameters": {
"operation": "set",
"variables": {
"step2_start": "{{$timestamp}}"
}
}
}
},
{
"id": "tracking_journey_2",
"type": "tracking",
"position": { "x": 1500, "y": 100 },
"data": {
"label": "Journey - Step 2 Iniciado",
"parameters": {
"trackingType": "user_journey",
"data": {
"step": 2,
"stepName": "Personal Info",
"funnel": "signup",
"previousStep": "Landing Page",
"nextStep": "Contact Info"
}
}
}
},
{
"id": "input_nome",
"type": "input",
"position": { "x": 1700, "y": 100 },
"data": {
"label": "Nome",
"parameters": {
"message": "Seu nome:",
"variable": "nome"
}
}
},
{
"id": "tracking_form",
"type": "tracking",
"position": { "x": 1900, "y": 100 },
"data": {
"label": "Form Submitted",
"parameters": {
"trackingType": "form_submission",
"data": {
"formId": "personal_info_form",
"formName": "Personal Information",
"fields": {
"name": "{{nome}}"
},
"success": true
}
}
}
},
{
"id": "tracking_journey_2_complete",
"type": "tracking",
"position": { "x": 2100, "y": 100 },
"data": {
"label": "Journey - Step 2 Completo",
"parameters": {
"trackingType": "user_journey",
"data": {
"step": 2,
"stepName": "Personal Info",
"funnel": "signup",
"previousStep": "Landing Page",
"timeSpent": 5,
"nextStep": "Contact Info"
}
}
}
},
{
"id": "tracking_conversion",
"type": "tracking",
"position": { "x": 2300, "y": 100 },
"data": {
"label": "Conversão",
"parameters": {
"trackingType": "conversion",
"data": {
"goalId": "partial_signup",
"goalName": "Partial Signup Completed",
"value": 10,
"currency": "BRL",
"category": "signup"
}
}
}
},
{
"id": "message_2",
"type": "message",
"position": { "x": 2500, "y": 100 },
"data": {
"label": "Sucesso",
"parameters": {
"message": "✅ Jornada rastreada, {{nome}}!\n\n📊 Eventos registrados:\n- 2 steps iniciados\n- 2 steps completados\n- 1 formulário enviado\n- 1 conversão"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 2700, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "variable_step1_start" },
{ "source": "variable_step1_start", "target": "tracking_journey_1" },
{ "source": "tracking_journey_1", "target": "message_1" },
{ "source": "message_1", "target": "delay_1" },
{ "source": "delay_1", "target": "tracking_journey_1_complete" },
{ "source": "tracking_journey_1_complete", "target": "variable_step2_start" },
{ "source": "variable_step2_start", "target": "tracking_journey_2" },
{ "source": "tracking_journey_2", "target": "input_nome" },
{ "source": "input_nome", "target": "tracking_form" },
{ "source": "tracking_form", "target": "tracking_journey_2_complete" },
{ "source": "tracking_journey_2_complete", "target": "tracking_conversion" },
{ "source": "tracking_conversion", "target": "message_2" },
{ "source": "message_2", "target": "end_1" }
]
}
Saída esperada:
Sistema: 👋 Bem-vindo! Vamos começar?
Sistema: Seu nome:
Usuário: Maria Silva
Sistema: ✅ Jornada rastreada, Maria Silva!
📊 Eventos registrados:
- 2 steps iniciados
- 2 steps completados
- 1 formulário enviado
- 1 conversão
Exemplo 2: A/B Testing com Rastreamento
Objetivo: Rastrear variantes de teste A/B e conversões
JSON para Importar
{
"name": "A/B Test Tracking",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "random_1",
"type": "random",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Sortear Variante",
"parameters": {
"type": "choice",
"choices": ["A", "B"],
"variable": "variant"
}
}
},
{
"id": "tracking_ab_assigned",
"type": "tracking",
"position": { "x": 500, "y": 100 },
"data": {
"label": "AB Test Assigned",
"parameters": {
"trackingType": "a_b_test",
"data": {
"experimentId": "exp_cta_button_2025",
"experimentName": "CTA Button Text",
"variant": "{{variant}}",
"converted": false
}
}
}
},
{
"id": "condition_1",
"type": "condition",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Qual Variante?",
"parameters": {
"conditions": [
{
"variable": "variant",
"operator": "equals",
"value": "A"
}
],
"logic": "AND"
}
}
},
{
"id": "message_a",
"type": "message",
"position": { "x": 900, "y": 50 },
"data": {
"label": "Variante A",
"parameters": {
"message": "🎯 VARIANTE A\n\n[Criar Minha Conta Grátis]"
}
}
},
{
"id": "message_b",
"type": "message",
"position": { "x": 900, "y": 150 },
"data": {
"label": "Variante B",
"parameters": {
"message": "🚀 VARIANTE B\n\n[Começar Agora]"
}
}
},
{
"id": "input_1",
"type": "input",
"position": { "x": 1100, "y": 100 },
"data": {
"label": "Quer testar?",
"parameters": {
"message": "Digite SIM para testar:",
"variable": "resposta"
}
}
},
{
"id": "tracking_click",
"type": "tracking",
"position": { "x": 1300, "y": 100 },
"data": {
"label": "Click no CTA",
"parameters": {
"trackingType": "click",
"data": {
"element": "button",
"text": "CTA Button",
"variant": "{{variant}}"
}
}
}
},
{
"id": "condition_2",
"type": "condition",
"position": { "x": 1500, "y": 100 },
"data": {
"label": "Converteu?",
"parameters": {
"conditions": [
{
"variable": "resposta",
"operator": "equals",
"value": "SIM"
}
],
"logic": "AND"
}
}
},
{
"id": "tracking_ab_converted",
"type": "tracking",
"position": { "x": 1700, "y": 50 },
"data": {
"label": "AB Test - Converteu",
"parameters": {
"trackingType": "a_b_test",
"data": {
"experimentId": "exp_cta_button_2025",
"experimentName": "CTA Button Text",
"variant": "{{variant}}",
"converted": true
}
}
}
},
{
"id": "tracking_ab_not_converted",
"type": "tracking",
"position": { "x": 1700, "y": 150 },
"data": {
"label": "AB Test - Não Converteu",
"parameters": {
"trackingType": "a_b_test",
"data": {
"experimentId": "exp_cta_button_2025",
"experimentName": "CTA Button Text",
"variant": "{{variant}}",
"converted": false
}
}
}
},
{
"id": "tracking_conversion",
"type": "tracking",
"position": { "x": 1900, "y": 50 },
"data": {
"label": "Conversão",
"parameters": {
"trackingType": "conversion",
"data": {
"goalId": "cta_click_goal",
"goalName": "CTA Clicked",
"value": 50,
"category": "engagement"
}
}
}
},
{
"id": "message_converted",
"type": "message",
"position": { "x": 2100, "y": 50 },
"data": {
"label": "Converteu",
"parameters": {
"message": "🎉 Ótimo!\n\nVariante {{variant}} → CONVERSÃO ✅\n\nDados registrados para análise do teste!"
}
}
},
{
"id": "message_not_converted",
"type": "message",
"position": { "x": 2100, "y": 150 },
"data": {
"label": "Não Converteu",
"parameters": {
"message": "Tudo bem!\n\nVariante {{variant}} → SEM CONVERSÃO\n\nDados registrados para análise do teste!"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 2300, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "random_1" },
{ "source": "random_1", "target": "tracking_ab_assigned" },
{ "source": "tracking_ab_assigned", "target": "condition_1" },
{ "source": "condition_1", "target": "message_a", "label": "true" },
{ "source": "condition_1", "target": "message_b", "label": "false" },
{ "source": "message_a", "target": "input_1" },
{ "source": "message_b", "target": "input_1" },
{ "source": "input_1", "target": "tracking_click" },
{ "source": "tracking_click", "target": "condition_2" },
{ "source": "condition_2", "target": "tracking_ab_converted", "label": "true" },
{ "source": "condition_2", "target": "tracking_ab_not_converted", "label": "false" },
{ "source": "tracking_ab_converted", "target": "tracking_conversion" },
{ "source": "tracking_conversion", "target": "message_converted" },
{ "source": "tracking_ab_not_converted", "target": "message_not_converted" },
{ "source": "message_converted", "target": "end_1" },
{ "source": "message_not_converted", "target": "end_1" }
]
}
Saída esperada (variante A, conversão):
Sistema: 🎯 VARIANTE A
[Criar Minha Conta Grátis]
Sistema: Digite SIM para testar:
Usuário: SIM
Sistema: 🎉 Ótimo!
Variante A → CONVERSÃO ✅
Dados registrados para análise do teste!
Eventos rastreados:
1. a_b_test (variant: A, converted: false) - Assignment
2. click (element: button, variant: A)
3. a_b_test (variant: A, converted: true) - Conversão
4. conversion (goal: cta_click_goal)
Exemplo 3: Form Analytics Completo
Objetivo: Rastrear interação detalhada com formulário
JSON para Importar
{
"name": "Form Analytics Complete",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "tracking_page",
"type": "tracking",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Page View - Form",
"parameters": {
"trackingType": "page_view",
"data": {
"page": "signup_form",
"title": "Formulário de Cadastro",
"url": "/signup"
}
}
}
},
{
"id": "message_1",
"type": "message",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Intro Form",
"parameters": {
"message": "📝 Formulário de Cadastro\n\nPreencha os campos abaixo:"
}
}
},
{
"id": "input_nome",
"type": "input",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Campo Nome",
"parameters": {
"message": "Nome completo:",
"variable": "nome"
}
}
},
{
"id": "email_1",
"type": "email",
"position": { "x": 900, "y": 100 },
"data": {
"label": "Campo Email",
"parameters": {
"message": "Email:",
"variable": "email"
}
}
},
{
"id": "phone_1",
"type": "phone",
"position": { "x": 1100, "y": 100 },
"data": {
"label": "Campo Telefone",
"parameters": {
"message": "Telefone:",
"variable": "telefone"
}
}
},
{
"id": "tracking_form_success",
"type": "tracking",
"position": { "x": 1300, "y": 100 },
"data": {
"label": "Form Submitted - Success",
"parameters": {
"trackingType": "form_submission",
"data": {
"formId": "signup_form_001",
"formName": "User Signup Form",
"fields": {
"name": "{{nome}}",
"email": "{{email}}",
"phone": "{{telefone}}"
},
"success": true,
"errors": []
}
}
}
},
{
"id": "tracking_conversion",
"type": "tracking",
"position": { "x": 1500, "y": 100 },
"data": {
"label": "Conversion",
"parameters": {
"trackingType": "conversion",
"data": {
"goalId": "form_signup_goal",
"goalName": "Signup Form Completed",
"value": 100,
"currency": "BRL",
"category": "signup"
}
}
}
},
{
"id": "message_2",
"type": "message",
"position": { "x": 1700, "y": 100 },
"data": {
"label": "Sucesso",
"parameters": {
"message": "✅ Cadastro completo!\n\n📊 Form Analytics:\n- Page view rastreada\n- 3 campos preenchidos\n- Form submitted com sucesso\n- Conversão registrada\n\nObrigado, {{nome}}!"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 1900, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "tracking_page" },
{ "source": "tracking_page", "target": "message_1" },
{ "source": "message_1", "target": "input_nome" },
{ "source": "input_nome", "target": "email_1" },
{ "source": "email_1", "target": "phone_1" },
{ "source": "phone_1", "target": "tracking_form_success" },
{ "source": "tracking_form_success", "target": "tracking_conversion" },
{ "source": "tracking_conversion", "target": "message_2" },
{ "source": "message_2", "target": "end_1" }
]
}
Saída esperada:
Sistema: 📝 Formulário de Cadastro
Preencha os campos abaixo:
Sistema: Nome completo:
Usuário: Carlos Silva
Sistema: Email:
Usuário: carlos@example.com
Sistema: Telefone:
Usuário: (11) 98765-4321
Sistema: ✅ Cadastro completo!
📊 Form Analytics:
- Page view rastreada
- 3 campos preenchidos
- Form submitted com sucesso
- Conversão registrada
Obrigado, Carlos Silva!
Resposta do Node
Page View:
{
"success": true,
"action": "page_view_tracked",
"data": {
"type": "page_view",
"page": "home",
"title": "Home Page",
"url": "/home",
"referrer": "/landing",
"userId": "user_456",
"sessionId": "session_123",
"timestamp": "2025-01-15T10:30:00.000Z"
},
"timestamp": "2025-01-15T10:30:00.000Z"
}
Form Submission:
{
"success": true,
"action": "form_submission_tracked",
"data": {
"type": "form_submission",
"formId": "signup_form",
"formName": "User Signup",
"fields": {
"name": "João Silva",
"email": "joao@example.com"
},
"success": true,
"errors": [],
"userId": "user_456",
"sessionId": "session_123",
"timestamp": "2025-01-15T10:30:00.000Z"
},
"timestamp": "2025-01-15T10:30:00.000Z"
}
A/B Test:
{
"success": true,
"action": "ab_test_tracked",
"data": {
"type": "a_b_test",
"experimentId": "exp_123",
"experimentName": "Button Color",
"variant": "red",
"converted": true,
"userId": "user_456",
"sessionId": "session_123",
"timestamp": "2025-01-15T10:30:00.000Z"
},
"timestamp": "2025-01-15T10:30:00.000Z"
}
Tracking Types Detalhados
page_view
Rastreia visualizações de página para análise de navegação. - Métricas: Pages per session, bounce rate, exit rate - Use para: Web analytics, heatmaps
click
Rastreia cliques em elementos específicos. - Métricas: Click-through rate, element engagement - Use para: Heatmaps, UX optimization
form_submission
Rastreia submissões de formulários. - Métricas: Form completion rate, field abandonment - Use para: Form optimization, conversion analysis
conversion
Rastreia atingimento de objetivos. - Métricas: Conversion rate, goal value, ROI - Use para: Goal tracking, revenue attribution
user_journey
Rastreia etapas da jornada do usuário. - Métricas: Step completion, time per step, drop-off - Use para: Funnel analysis, journey mapping
a_b_test
Rastreia experimentos e variantes. - Métricas: Variant performance, conversion lift - Use para: A/B testing, feature experiments
Boas Práticas
✅ SIM: - Use trackingType apropriado para cada caso - Sempre inclua dados contextuais em "data" - Rastreie início E conclusão de ações - Use sessionId para correlacionar eventos - Combine com CONVERSION para medir resultados - Documente estrutura de data para cada tipo
❌ NÃO: - Não misture tipos de tracking em um evento - Não omita campos importantes de data - Não rastreie dados sensíveis sem consent - Não abuse de tracking (performance) - Não esqueça de testar rastreamento
Dicas
💡 Page Views: Rastreie sempre no início de cada "tela" do flow
💡 Formulários: Rastreie form_submission mesmo em caso de erro (success: false)
💡 Journey: Use timeSpent para identificar etapas problemáticas
💡 A/B Tests: Sempre rastreie assignment E resultado do teste
💡 Conversions: Associe valor monetário sempre que possível
💡 Click Tracking: Inclua position para criar heatmaps
Próximo Node
→ ANALYTICS - Rastreamento com providers externos → EVENT - Eventos de negócio genéricos → METRIC - Métricas numéricas e KPIs → LOGGER - Logs estruturados