dataLayer
Qué hace dataLayer.push
dataLayer.push añade un objeto a window.dataLayer. Una etiqueta puede leer ese objeto y enviar un hit. Con el consentimiento apagado ves el push y luego se detiene. Con el consentimiento encendido ves el hit collect decodificado junto al push que lo provocó.
¿Qué es el dataLayer?
El dataLayer es el array window.dataLayer. Es una lista, no una petición. dataLayer.push pone un objeto en esa lista. La nota De un push a un hit de Google sigue un push hasta un hit, y el laboratorio de tag manager muestra qué etiqueta lo leería.
Entender el laboratorioCómo usarlo y por qué querrías hacerlo
Por qué querrías hacerlo
Probar recorre un push por la acción, la cola, la etiqueta de GA4, la comprobación de consentimiento y la petición collect. El consentimiento apagado deja el evento en la página, y el encendido usa la misma cola que el resto del sitio.
Cómo usarlo
- Elige un evento que el sitio ya conoce y pulsa Probar.
- Cinco etapas avanzan de una en una.
- El consentimiento apagado muestra el push y se detiene antes del hit.
- El consentimiento encendido decodifica el hit collect. El almacenamiento de publicidad sigue apagado.
Qué es el dataLayer
window.dataLayer es un array en la página. Es una cola, no un informe. Este sitio hace push de comandos. La etiqueta de Google lee la cola y decide qué enviar, si es que envía algo.
gtag() son unas líneas instaladas antes de que llegue el script de Google: function gtag(){dataLayer.push(arguments);}. Llamar a dataLayer.push({ event: 'virtual_page_view', page_path: '/' }) añade ese objeto al array. Los comandos de consentimiento siguen usando el shim gtag, porque Consent Mode lee un objeto arguments.
gtm.js carga desde googletagmanager.com solo después de Aceptar. GA4 es una etiqueta de ese contenedor, y este sitio no carga gtag.js por su cuenta. Los eventos que ya esperaban se tratan en orden. Una navegación envía virtual_page_view, así que la etiqueta de GA4 no debe enviar su propio page view. El contenedor también debe descartar su scroll automático para no duplicar el scroll de este sitio. segment_update lleva la propiedad de usuario segments.
Una visita denegada no carga la etiqueta. Este sitio también retiene gtag('event', …) hasta Aceptar, así que una visita denegada no produce ningún hit collect. Los botones Probar siguen mostrando el push y luego se detienen en la comprobación de consentimiento.
Un evento granted se convierte en una petición a https://www.google-analytics.com/g/collect. La query string, y el cuerpo cuando varios eventos van en lote, llevan estos campos.
- en
- Nombre del evento en el hit collect. Un push virtual_page_view debe llegar como page_view cuando el contenedor lo mapea. Los demás nombres coinciden con el esquema de abajo.
- tid
- Measurement id de esta propiedad. En este sitio es G-JDE6BF33RY.
- cid
- Client id. Después del consentimiento, Google lo guarda en la cookie _ga para que los hits posteriores se puedan unir al mismo navegador.
- sid
- Session id de la visita actual.
- gcs
- Estado de consentimiento. El valor empieza por G1, luego un dígito para ad storage y otro para analytics storage. 1 es granted y 0 es denied. G101 significa que analytics está granted y ads están denied, que es este sitio después de Aceptar. G100 significa que ambos están denied.
- dl
- Document location. La URL de la página a la que se refiere el hit.
- dt
- Document title.
- ep.*
- Parámetros del evento. ep.page_path, ep.percent_scrolled, ep.link_url y el resto de campos que este sitio adjuntó al evento.
- up.*
- Propiedades de usuario. up.segments es la lista separada por comas que se fija con el evento segment_update.
Canal en vivo
Consentimiento denied
Cada comando nuevo recorre los mismos cinco pasos. El payload bajo la fila es el del paso resaltado. Con el consentimiento apagado, Probar termina en un paso de red bloqueado y no se envía nada.
Esperando el siguiente push. Usa un botón Probar, acepta el consentimiento y muévete por el sitio, o haz scroll en esta página.
Inspector del dataLayer
Cada push desde que cargó esta página, el más reciente primero. Después de Aceptar eso incluye el consent default, gtm.js y eventos posteriores como virtual_page_view. Antes de Aceptar Google Tag Manager no está cargado. Las filas Probar denegadas no se empujaron a la cola real.
Aún no hay pushes para este filtro.
Hits de GA decodificados
Peticiones /g/collect salientes, capturadas envolviendo sendBeacon, fetch y XMLHttpRequest, con PerformanceObserver de respaldo. El lado izquierdo es el push. El derecho es la query decodificada. Las claves resaltadas son las descritas arriba.
Ninguna petición collect. El consentimiento está apagado, así que Probar se detiene antes de enviar un hit.
Esquema de eventos
Estos son los eventos que envía este sitio. Los correos, los nombres y los valores de formulario nunca son parámetros. login y sign_up usan siempre method password.
virtual_page_view
Every App Router navigation, once, after measurement consent is on. The GA4 tag in GTM should not send its own page view.
page_location, page_path, page_title, page_referrer, previous_page_path, page_path_depth, path_sequence
click
A same-site link, button, or control click. External links use outbound_click instead.
link_url, link_text, element_id, outbound, experiment_id, variant
outbound_click
An external link click, including LinkedIn, Instagram, and the sister sites. Sister sites set link_type to sister_site. Pushed even when consent is off. GTM still waits for consent.
link_url, link_domain, link_type
scroll
The first time a page that is not a blog post crosses 25, 50, 75, or 90 percent, after consent.
percent_scrolled
scroll_depth
A blog post crosses 25, 50, 75, or 90 percent. Once per milestone per page view. Pushed even when consent is off.
percent_scrolled, post_slug
lab_interaction
A lab panel opens, a demo or test runs, JSON is edited, or the floating inspector opens. Pushed even when consent is off.
lab_id, action, label
file_download
The white paper PDF download link is clicked.
file_name
video_start
The lab clip or the consented YouTube embed starts. Measurement consent is required. No account id.
video_title, video_provider, video_url, video_duration, video_current_time
video_progress
The player crosses 10, 25, 50, 75, 90, or 100 percent. Once per milestone per view.
video_percent, video_title, video_provider, video_url, video_duration, video_current_time
video_complete
The player reaches the end.
video_title, video_provider, video_url, video_duration
video_engagement
Pause, seek, rate, mute, volume, fullscreen, picture-in-picture, captions, buffering, startup, or visibility. Category params only.
video_action, video_provider, video_current_time, video_percent, playback_rate, visible_percent
consent_update
Measurement consent is on. A denial does not push an event.
analytics_granted
login
A password sign-in succeeds.
method
sign_up
A password account is created, an existing sign-in checks the newsletter box, or the account page turns announcements on. newsletter_opt_in is true only for that opt-in.
method, newsletter_opt_in
logout
The visitor signs out.
ninguno
generate_lead
The contact form stores a message (form_id contact), the home consultation does (form_id free_consultation), or the white paper form stores a lead (form_name white_paper). No name, email, company, or message text. The contact event is pushed only after the server confirms the save.
form_id, form_name
view_item
A blog post page is viewed.
content_type, item_id
select_content
A recommended-next card is clicked.
content_type, item_id, recommendation_reason
segment_update
The on-segments for this browser change. segments is a comma-separated list. Copy it onto the GA4 user property segments in GTM. This site does not call gtag('set').
segments
personalization_exposure
The personalized rules currently changing this page change.
personalization_rule
weather_personalization_view
The weather lab has a live forecast. The parameter is the matched rule id. Coordinates are not sent.
weather_rule
white_paper_view
The white paper landing page is viewed with consent on. No form fields are parameters.
ninguno
experiment_personalization_view
The experiments lab assigns this browser. Arms are a or b. No visitor key is sent.
ab_arm, bandit_arm
context_personalization_view
The context lab is showing the live clock. The parameter is the matched rule id. The timezone and the clock time are not sent.
context_rule
source_personalization_view
The source lab is showing this visit, not a simulator preset. The parameter is the rule id. Referrer URLs and campaign values are not sent.
source_rule
intent_personalization_view
The intent lab is using this visit, not the sliders. intent_ready is true at a score of 40 or more. The score and the signals are not sent.
intent_ready
exit_intent_view
A live exit rule matches with consent on. exit_trigger is mouseout, scroll, or back. The Try it buttons do not send it.
exit_trigger
profiling_personalization_view
The profiling lab has stored answers available. profile_step is role, goal, industry, or complete. The chosen answers are not sent.
profile_step
ai_copy_view
The AI copy lab has a segment selected and consent is on. copy_engine is template or openai. The headline text is not sent.
copy_engine, copy_segment
ask_view
The ask lab is showing a statement and consent is on. data_source is stored or sample. ask_engine is preset, keyword, or openai. The question text is not sent.
data_source, ask_engine
llms_txt_view
The llms.txt lab is open and measurement consent is on. fetch_count is how many logged AI user agents have requested /llms.txt. The file body is not sent.
fetch_count
trends_view
A Trends comparison finishes and measurement consent is on. data_source is website, serpapi, or unreachable. The terms are not sent.
data_source
trends_gap_view
The Trends and Search Console lab finishes a comparison and measurement consent is on. data_source is search_console, unreachable, or example. Queries and terms are not sent.
data_source
ai_referral_detected
An AI referrer or utm_source is classified and measurement consent is on. assistant is the list id, such as chatgpt or perplexity. The referrer URL and the campaign string are not sent.
assistant
get_found_view
The get-found guide is open and measurement consent is on. done_count is how many checklist steps are files or tags on this site. Search queries and account names are not sent.
done_count
pagespeed_test
A PageSpeed run finishes and measurement consent is on. tested_path is the pathname only. strategy is mobile or desktop. perf_score is the Lighthouse performance score from 0 to 100. The full URL is not sent.
tested_path, strategy, perf_score
seo_inspect
An inspection of a URL on this site finishes and measurement consent is on. inspected_path is the pathname only. warn_count is how many checks warned. Titles, descriptions, and query strings are not sent.
inspected_path, warn_count
sitemap_view
The sitemap lab is open and measurement consent is on. snapshot_count is how many stored snapshots are on the page. change_count is how many URLs were added, removed, or had a lastmod edit in the diff on screen. URLs are not sent.
snapshot_count, change_count
jsonld_view
The JSON-LD lab is showing a path and measurement consent is on. inspected_path is the pathname only. script_count is how many JSON-LD scripts that path emits. warn_count is how many checks warned. The graph body is not sent.
inspected_path, script_count, warn_count
quality_view
The data-quality lab has a status table and consent is on. data_source is stored or sample. failing_checks is a count. Paths are not sent.
data_source, failing_checks
bots_view
The bots lab has counts on screen and consent is on. data_source is stored or sample. User-Agent strings are not sent.
data_source
significance_view
The significance lab has counts on screen and consent is on. data_source is stored or sample. The rates are not sent.
data_source
anomaly_view
The anomaly lab has a series on screen and consent is on. data_source is stored or sample. Counts are not sent.
data_source
cohort_view
The cohort lab has a grid on screen and consent is on. data_source is stored or sample. Visitor ids are not sent.
data_source
funnel_view
The funnel lab has counts on screen and consent is on. data_source is stored or sample. Filter values are not sent.
data_source
attribution_view
The attribution lab has a journey on screen and consent is on. data_source is stored or sample. Channels are not sent.
data_source
performance_view
The performance lab is open and consent is on. LCP, INP, CLS, and TTFB values are not sent.
ninguno
form_lab_view
The form analytics lab is open and consent is on. Field values, skips, and timings are not sent.
ninguno
utm_builder_view
The UTM builder is open and consent is on. The campaign parameters are not sent.
ninguno
blocking_view
The blocking lab finished its tag check and consent is on. analytics_blocked is true when the Google host did not respond. Counts are not sent.
analytics_blocked
fingerprint_view
The fingerprint lab has rendered and consent is on. Screen, fonts, languages, and the canvas hash are not parameters.
ninguno
consent_lab_view
The consent lab is open and measurement consent is on. gpc is true when Global Privacy Control is on. No cookie values are sent.
gpc
reset_my_data
The visitor confirms Reset my data and measurement consent is on. Fired before cookies and storage are cleared. reset_surface is cookies, footer, account, home, or settings. No ids or cookie values.
reset_surface
cookies_view
The cookies lab has listed storage names and consent is on. Cookie values and ids are not sent.
ninguno
server_side_view
The server-side lab has loaded and consent is on. server_transport is measurement_protocol or database. The secret and the client id are not sent.
server_transport
tag_manager_view
The tag manager lab has fired a simulated tag and consent is on. fired_count is how many tags matched the last click. The click text is not sent.
fired_count
enhanced_measurement_view
The enhanced measurement lab is open and consent is on. No event parameters from the practice controls are sent.
ninguno
ecommerce_demo
A demo ecommerce step is taken and consent is on. step is view_item, add_to_cart, begin_checkout, or purchase. The item name and price are not sent.
step
heatmap_view
The heatmap lab has a table and consent is on. data_source is stored or sample. Paths and coordinates are not sent.
data_source
cross_domain_view
The cross-domain lab is open and consent is on. The destination and the decorated URL are not sent.
ninguno
spa_tracking_view
The SPA tracking lab changes mode and consent is on. mode is naive or history. The demo path is not sent.
mode
session_replay_view
The session replay lab is open and consent is on. masked is true when input values are hidden in the local recording. Field values are not sent.
masked
event_quality_view
An event check finishes and consent is on. finding_count is how many problems were listed. The pasted event is not sent.
finding_count
app_tracking_view
The app tracking lab is open and consent is on. The simulated app instance id is not sent.
ninguno
offline_conversion_view
An offline conversion send finishes and consent is on. transport is measurement_protocol or simulated. The client id, the lead id, and the value are not sent.
transport
webhook_lab_view
A webhook lab send finishes and consent is on. webhook_event is the event name. destination is builtin or custom. The URL, the payload, and the signature are not sent.
webhook_event, destination, attempt_count
why_labels_view
The visitor turns Why labels on and consent is on. No rule text or signal values are sent.
why_labels
chat_open
The corner assistant opens, or the chatbot lab Try it panel is on screen, and measurement consent is on. chat_surface is corner or lab. chat_locale is en or es. The question is not sent.
chat_surface, chat_locale
starter_used
A starter chip is used and consent is on. chat_starter_id is the chip id, such as datalayer. The starter sentence is not sent.
chat_surface, chat_locale, chat_starter_id
question_asked
A question is sent and consent is on. chat_question_length is short, medium, or long. The question text is not sent.
chat_surface, chat_locale, chat_question_length
answer_shown
An answer is shown and consent is on. chat_status is ok, fallback, or refused. chat_source_count is an integer. chat_latency_bucket is under_2s, 2_5s, or over_5s. The answer text is not sent.
chat_surface, chat_locale, chat_status, chat_source_count, chat_latency_bucket
source_clicked
A source link in the assistant or the Try it panel is clicked and consent is on. chat_source_path is the pathname. The question is not sent.
chat_surface, chat_locale, chat_source_path
chat_close
The corner assistant panel closes and consent is on. chat_surface and chat_locale only. The lab panel does not close, so it does not send this.
chat_surface, chat_locale
experiment_conversion
A click on a live experiment's next step, after consent. The seeded ledger experiment is awaiting approval, so this push does not fire for it. No visitor id.
experiment_id, variant, conversion_name
RecorridoCómo lo hicimosMostrarOcultar
El ajuste de proveedor de ejemplo está marcado abajo. Los números de eVar y de event son ejemplos. Este laboratorio no llama a Adobe.
El laboratorio de dataLayer avanza un push etapa por etapa: la acción, el objeto de la cola, la etiqueta de GA4, la comprobación de consentimiento y la petición collect. Probar llama a demonstrateEvent. Con el consentimiento apagado, el evento se queda en la página. Con el consentimiento encendido, pasa a la misma cola que usa el resto del sitio. El laboratorio no llama a Adobe.
Ofrecer los eventos que el sitio ya conoce
Los botones nombran virtual_page_view, click, scroll, view_item, select_content, generate_lead, white_paper_view, segment_update, personalization_exposure, login, sign_up y logout.
Hacer push solo a través de la compuerta de consentimiento
demonstrateEvent limpia los parámetros. Si el consentimiento está apagado, registra una vista previa denegada y no llama a la etiqueta. Si está encendido, usa pushEvent, que escribe el dataLayer.
Recorrer cinco etapas
La página avanza de la acción del usuario a dataLayer.push, la etiqueta de GA4, la comprobación de consentimiento y la petición collect. El movimiento reducido se salta la espera.
Decodificar un hit concedido
Con el consentimiento encendido, el laboratorio puede mostrar la petición collect junto al push. Un nombre de evento se vuelve en. Un parámetro se vuelve un campo ep. segment_update.segments es la propiedad de usuario que se espera que copie el contenedor.
Dejar la publicidad apagada
Una etapa concedida sigue diciendo que ad storage permanece denied. Esta página no carga una etiqueta de anuncios.
Del código
La compuerta de Probar. Un rechazo nunca llega a pushEvent.
for (const listener of listeners) listener()
window.dispatchEvent(new CustomEvent(DATA_LAYER_EVENT, { detail: entry }))
}
function queueDataLayer(payload: Record<string, unknown>) {
loadGoogleAnalytics()
window.dataLayer = window.dataLayer || []
window.dataLayer.push(payload)
}
/** Pushes an event even when measurement consent is off. Does not load GTM. */
export function pushAnalyticsEvent(name: string, params: Params) {
if (typeof window === "undefined") return falseTodos los botones de muestra terminan aquí.
function tryEvent(name: string, params: Record<string, string | number | boolean>) {
demonstrateEvent(name, params)
}Google y Adobe
Google encola click después de Aceptar. Adobe es un ejemplo de los mismos campos.
Probar encola el evento nombrado en el botón, y solo después de Aceptar. El botón de clic encola click. Los otros botones encolan virtual_page_view, scroll, view_item, select_content, generate_lead, white_paper_view, segment_update, personalization_exposure, login, sign_up o logout. demonstrateEvent no hace push cuando el consentimiento está denegado. Estos son los nombres de evento reales del sitio. Esta página no llama a gtag('set') ni a Adobe.
Forma simplificada del objeto encolado después de Aceptar. Registra cualquier parámetro nuevo como dimensión personalizada con alcance de evento. Este sitio no llama a gtag('set').
dataLayer.push({
event: "click",
link_url: "/lab/datalayer",
element_id: "try-click",
outbound: false,
})Implementación de ejemplo. Este sitio no llama a Adobe. eVar34, prop34 y event34 son números de variable de ejemplo. En Launch, un elemento de datos lee el valor y una regla lo envía cuando el valor cambia. En el report suite, habilita eVar34 con asignación Most Recent y haz que expire en el hit. Una processing rule no hace falta si el elemento de datos se mapea directo a esa eVar.
Payload de alloy de ejemplo. _example es un esquema de relleno, no un inquilino real.
alloy("sendEvent", {
xdm: {
eventType: "web.webinteraction.linkClicks",
_example: {
eventName: "click",
},
},
})Hit de ejemplo. eVar34 tiene alcance de hit en este ejemplo. prop34 muere en el mismo hit.
s.eVar34 = "click"
s.prop34 = "click"
s.events = "event34"
s.linkTrackVars = "eVar34,prop34,events"
s.linkTrackEvents = "event34"
s.tl(true, "o", "click")Traducción
Cada campo del laboratorio, el nombre en GA4 y la variable de Adobe de ejemplo. El alcance es la parte que suele perderse en la traducción.
Nombre del evento
GA4. El nombre del evento en el dataLayer. En el hit collect se vuelve en.
Adobe. Nombre de enlace s.tl de ejemplo. event34 cuenta el hit de ejemplo.
Alcance. Evento.
Parámetro
GA4. Un parámetro plano se vuelve un campo ep. Los parámetros de artículo se quedan en el artículo.
Adobe. eVar34 de ejemplo para un parámetro en el hit. No se envía.
Alcance. Evento. No promociones un parámetro de una sola vez a propiedad de usuario.
segments en segment_update
GA4. Se espera que el contenedor copie segments a la propiedad segments con alcance de usuario. El laboratorio no llama a gtag('set').
Adobe. eVar35 de ejemplo, Most Recent, expira en la visita, si reflejaras esa lista. No se envía.
Alcance. El parámetro tiene alcance de evento. La propiedad de usuario dura hasta el siguiente set.
Resultado del consentimiento
GA4. Un Probar denegado no hace push. Uno concedido puede recogerse, con ad storage aún denied.
Adobe. Ejemplo: sáltate s.tl cuando el consentimiento está denegado.
Alcance. Una compuerta.
Recomendado a continuación
Por qué estas propuestasLeyendo las transiciones de recorrido…