Teste da API de Coleta
Endpoint
http://localhost/sgtm-tracker/api/collect.php
Enviar Evento
Nome do Evento
page_view
click
purchase
add_to_cart
form_submit
custom_event
Dados do Evento (JSON)
{ "page_title": "Página de Teste", "page_url": "/api/test.php", "value": 99.90, "currency": "BRL" }
Pageview
Compra
Carrinho
Formulário
Enviar Evento
Enviar 10 Eventos
Código JavaScript
// Exemplo de integração no seu site function sendEventToSGTM(eventName, eventData) { fetch('http://localhost/sgtm-tracker/api/collect.php', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ event_name: eventName, client_id: getClientId(), // Seu client ID session_id: getSessionId(), // Seu session ID event_data: eventData, page_url: window.location.href }) }) .then(response => response.json()) .then(data => console.log('Event sent:', data)) .catch(error => console.error('Error:', error)); } // Exemplo de uso sendEventToSGTM('page_view', { page_title: document.title, page_path: window.location.pathname });