[{"data":1,"prerenderedAt":2159},["ShallowReactive",2],{"article-alternates":3,"article-\u002Fit\u002Fdata\u002Fserver-side-gtm-conversion-api-production":13},{"i18nKey":4,"paths":5},"data-001-2026-06",{"de":6,"en":7,"es":8,"fr":9,"it":10,"ru":11,"tr":12},"\u002Fde\u002Fdata\u002Fserver-side-gtm-conversion-api-production","\u002Fen\u002Fdata\u002Fserver-side-gtm-conversion-api-production","\u002Fes\u002Fdata\u002Fserver-side-gtm-conversion-api-produccion","\u002Ffr\u002Fdata\u002Fserveur-gtm-conversion-api-production","\u002Fit\u002Fdata\u002Fserver-side-gtm-conversion-api-production","\u002Fru\u002Fdata\u002Fserver-side-gtm-conversion-api-production","\u002Ftr\u002Fdata\u002Fserver-side-gtm-ve-conversion-api-sifirdan-productiona",{"_path":10,"_dir":14,"_draft":15,"_partial":15,"_locale":16,"title":17,"description":18,"publishedAt":19,"modifiedAt":19,"category":14,"i18nKey":4,"tags":20,"readingTime":26,"author":27,"body":28,"_type":2153,"_id":2154,"_source":2155,"_file":2156,"_stem":2157,"_extension":2158},"data",false,"","Server-Side GTM e Conversion API: Da Zero a Production","Deploy su Cloud Run\u002FWorkers, container template, strategie di deduplicazione. Guida tecnica per portare il server-side measurement in produzione.","2026-06-12",[21,22,23,24,25],"server-side-gtm","conversion-api","cloud-run","event-deduplication","privacy-measurement",9,"Roibase",{"type":29,"children":30,"toc":2141},"root",[31,39,46,68,179,184,330,340,350,357,392,431,444,450,473,478,572,577,788,808,825,831,850,888,907,963,969,989,1001,1050,1055,1376,1396,1430,1436,1455,1460,1553,1565,1582,1588,1593,1680,1688,1742,1767,1773,1803,1808,1839,1878,2093,2119,2123,2135],{"type":32,"tag":33,"props":34,"children":35},"element","p",{},[36],{"type":37,"value":38},"text","L'eliminazione dei cookie, l'irrigidimento dell'ITP, il Consent Mode obbligatorio — la misurazione basata sul browser dal 2024 in poi subisce una perdita di segnali del 30-40%. I tag lato client non offrono più \"visibilità completa\". Il server-side measurement è l'unico approccio ingegneristico per recuperare questi segnali persi. Google Tag Manager Server Container (sGTM) e Meta Conversion API sono i due componenti fondamentali di questa architettura. Ma non è semplice come \"deployare e sperare\": hosting del container, deduplicazione degli eventi, gestione dei timeout, arricchimento parametrico dei dati — ogni fase richiede decisioni tecniche precise. Questo articolo affronta il trasferimento di sGTM su Cloud Run o Cloudflare Workers, l'integrazione con CAPI, la logica di deduplicazione e la checklist di produzione.",{"type":32,"tag":40,"props":41,"children":43},"h2",{"id":42},"host-del-container-server-side-gtm-cloud-run-vs-workers-vs-app-engine",[44],{"type":37,"value":45},"Host del Container Server-Side GTM: Cloud Run vs Workers vs App Engine",{"type":32,"tag":33,"props":47,"children":48},{},[49,51,57,59,66],{"type":37,"value":50},"Il container di sGTM può girare su Google Cloud, ma il ",{"type":32,"tag":52,"props":53,"children":54},"strong",{},[55],{"type":37,"value":56},"deploy manuale è obbligatorio",{"type":37,"value":58},". Se usi App Engine Automatic Scaling, i cold start durano 2-3 secondi; in caso di picchi di traffico c'è un rischio di drop di evento del 15-20%. Cloud Run è preferibile: minimo 1 istanza \"sempre attiva\", concorrenza 80-100, timeout della richiesta 10 secondi. Google mette a disposizione il template di Dockerfile in un repo pubblico — ",{"type":32,"tag":60,"props":61,"children":63},"code",{"className":62},[],[64],{"type":37,"value":65},"gcr.io\u002Fcloud-tagging-10302018\u002Fgtm-cloud-image:stable",{"type":37,"value":67},". Quando fai il deploy di questa immagine al tuo progetto, sono obbligatorie 3 variabili d'ambiente:",{"type":32,"tag":69,"props":70,"children":74},"pre",{"className":71,"code":72,"language":73,"meta":16,"style":16},"language-bash shiki shiki-themes github-dark","CONTAINER_CONFIG=\u003CGTM server container ID>\nPREVIEW_SERVER_URL=https:\u002F\u002F\u003Cpreview-domain>\nRUN_AS_HTTPS_SERVER=true\n","bash",[75],{"type":32,"tag":60,"props":76,"children":77},{"__ignoreMap":16},[78,128,161],{"type":32,"tag":79,"props":80,"children":83},"span",{"class":81,"line":82},"line",1,[84,90,96,102,108,113,118,123],{"type":32,"tag":79,"props":85,"children":87},{"style":86},"--shiki-default:#E1E4E8",[88],{"type":37,"value":89},"CONTAINER_CONFIG",{"type":32,"tag":79,"props":91,"children":93},{"style":92},"--shiki-default:#F97583",[94],{"type":37,"value":95},"=\u003C",{"type":32,"tag":79,"props":97,"children":99},{"style":98},"--shiki-default:#9ECBFF",[100],{"type":37,"value":101},"GTM",{"type":32,"tag":79,"props":103,"children":105},{"style":104},"--shiki-default:#B392F0",[106],{"type":37,"value":107}," server",{"type":32,"tag":79,"props":109,"children":110},{"style":98},[111],{"type":37,"value":112}," container",{"type":32,"tag":79,"props":114,"children":115},{"style":98},[116],{"type":37,"value":117}," I",{"type":32,"tag":79,"props":119,"children":120},{"style":86},[121],{"type":37,"value":122},"D",{"type":32,"tag":79,"props":124,"children":125},{"style":92},[126],{"type":37,"value":127},">\n",{"type":32,"tag":79,"props":129,"children":131},{"class":81,"line":130},2,[132,137,142,147,152,157],{"type":32,"tag":79,"props":133,"children":134},{"style":86},[135],{"type":37,"value":136},"PREVIEW_SERVER_URL",{"type":32,"tag":79,"props":138,"children":139},{"style":92},[140],{"type":37,"value":141},"=",{"type":32,"tag":79,"props":143,"children":144},{"style":98},[145],{"type":37,"value":146},"https:\u002F\u002F",{"type":32,"tag":79,"props":148,"children":149},{"style":92},[150],{"type":37,"value":151},"\u003C",{"type":32,"tag":79,"props":153,"children":154},{"style":98},[155],{"type":37,"value":156},"preview-domain",{"type":32,"tag":79,"props":158,"children":159},{"style":92},[160],{"type":37,"value":127},{"type":32,"tag":79,"props":162,"children":164},{"class":81,"line":163},3,[165,170,174],{"type":32,"tag":79,"props":166,"children":167},{"style":86},[168],{"type":37,"value":169},"RUN_AS_HTTPS_SERVER",{"type":32,"tag":79,"props":171,"children":172},{"style":92},[173],{"type":37,"value":141},{"type":32,"tag":79,"props":175,"children":176},{"style":98},[177],{"type":37,"value":178},"true\n",{"type":32,"tag":33,"props":180,"children":181},{},[182],{"type":37,"value":183},"Esempio di comando per Cloud Run:",{"type":32,"tag":69,"props":185,"children":187},{"className":71,"code":186,"language":73,"meta":16,"style":16},"gcloud run deploy sgtm-prod \\\n  --image=gcr.io\u002Fcloud-tagging-10302018\u002Fgtm-cloud-image:stable \\\n  --platform=managed \\\n  --region=europe-west1 \\\n  --set-env-vars=CONTAINER_CONFIG=GTM-XXXXXX,RUN_AS_HTTPS_SERVER=true \\\n  --min-instances=1 \\\n  --max-instances=10 \\\n  --concurrency=80 \\\n  --timeout=10s \\\n  --memory=512Mi\n",[188],{"type":32,"tag":60,"props":189,"children":190},{"__ignoreMap":16},[191,220,232,244,257,270,283,296,309,321],{"type":32,"tag":79,"props":192,"children":193},{"class":81,"line":82},[194,199,204,209,214],{"type":32,"tag":79,"props":195,"children":196},{"style":104},[197],{"type":37,"value":198},"gcloud",{"type":32,"tag":79,"props":200,"children":201},{"style":98},[202],{"type":37,"value":203}," run",{"type":32,"tag":79,"props":205,"children":206},{"style":98},[207],{"type":37,"value":208}," deploy",{"type":32,"tag":79,"props":210,"children":211},{"style":98},[212],{"type":37,"value":213}," sgtm-prod",{"type":32,"tag":79,"props":215,"children":217},{"style":216},"--shiki-default:#79B8FF",[218],{"type":37,"value":219}," \\\n",{"type":32,"tag":79,"props":221,"children":222},{"class":81,"line":130},[223,228],{"type":32,"tag":79,"props":224,"children":225},{"style":216},[226],{"type":37,"value":227},"  --image=gcr.io\u002Fcloud-tagging-10302018\u002Fgtm-cloud-image:stable",{"type":32,"tag":79,"props":229,"children":230},{"style":216},[231],{"type":37,"value":219},{"type":32,"tag":79,"props":233,"children":234},{"class":81,"line":163},[235,240],{"type":32,"tag":79,"props":236,"children":237},{"style":216},[238],{"type":37,"value":239},"  --platform=managed",{"type":32,"tag":79,"props":241,"children":242},{"style":216},[243],{"type":37,"value":219},{"type":32,"tag":79,"props":245,"children":247},{"class":81,"line":246},4,[248,253],{"type":32,"tag":79,"props":249,"children":250},{"style":216},[251],{"type":37,"value":252},"  --region=europe-west1",{"type":32,"tag":79,"props":254,"children":255},{"style":216},[256],{"type":37,"value":219},{"type":32,"tag":79,"props":258,"children":260},{"class":81,"line":259},5,[261,266],{"type":32,"tag":79,"props":262,"children":263},{"style":216},[264],{"type":37,"value":265},"  --set-env-vars=CONTAINER_CONFIG=GTM-XXXXXX,RUN_AS_HTTPS_SERVER=true",{"type":32,"tag":79,"props":267,"children":268},{"style":216},[269],{"type":37,"value":219},{"type":32,"tag":79,"props":271,"children":273},{"class":81,"line":272},6,[274,279],{"type":32,"tag":79,"props":275,"children":276},{"style":216},[277],{"type":37,"value":278},"  --min-instances=1",{"type":32,"tag":79,"props":280,"children":281},{"style":216},[282],{"type":37,"value":219},{"type":32,"tag":79,"props":284,"children":286},{"class":81,"line":285},7,[287,292],{"type":32,"tag":79,"props":288,"children":289},{"style":216},[290],{"type":37,"value":291},"  --max-instances=10",{"type":32,"tag":79,"props":293,"children":294},{"style":216},[295],{"type":37,"value":219},{"type":32,"tag":79,"props":297,"children":299},{"class":81,"line":298},8,[300,305],{"type":32,"tag":79,"props":301,"children":302},{"style":216},[303],{"type":37,"value":304},"  --concurrency=80",{"type":32,"tag":79,"props":306,"children":307},{"style":216},[308],{"type":37,"value":219},{"type":32,"tag":79,"props":310,"children":311},{"class":81,"line":26},[312,317],{"type":32,"tag":79,"props":313,"children":314},{"style":216},[315],{"type":37,"value":316},"  --timeout=10s",{"type":32,"tag":79,"props":318,"children":319},{"style":216},[320],{"type":37,"value":219},{"type":32,"tag":79,"props":322,"children":324},{"class":81,"line":323},10,[325],{"type":32,"tag":79,"props":326,"children":327},{"style":216},[328],{"type":37,"value":329},"  --memory=512Mi\n",{"type":32,"tag":33,"props":331,"children":332},{},[333,338],{"type":32,"tag":52,"props":334,"children":335},{},[336],{"type":37,"value":337},"Alternativa Cloudflare Workers:",{"type":37,"value":339}," Se la latenza edge globale è una priorità, puoi usare Workers. Portare la logica del container di GTM al runtime di Workers è necessario (non è nativo). Il vantaggio: response time sotto i 50ms; lo svantaggio: l'ecosistema dei template di tag è limitato — dovrai scrivere JavaScript personalizzato.",{"type":32,"tag":33,"props":341,"children":342},{},[343,348],{"type":32,"tag":52,"props":344,"children":345},{},[346],{"type":37,"value":347},"Costo di hosting:",{"type":37,"value":349}," Su Cloud Run, circa 1M di richieste al mese costa $40-60 (1 istanza sempre accesa + autoscale incluso). App Engine Flex costa $150-200. Workers costano $5 base + $0,50\u002Fmilione di richieste — molto più economico, ma senza supporto nativo di sGTM, richiede tempo di sviluppo extra.",{"type":32,"tag":351,"props":352,"children":354},"h3",{"id":353},"dominio-personalizzato-e-certificato-ssl",[355],{"type":37,"value":356},"Dominio personalizzato e certificato SSL",{"type":32,"tag":33,"props":358,"children":359},{},[360,362,368,370,375,377,382,384,390],{"type":37,"value":361},"Il dominio di default di sGTM ",{"type":32,"tag":60,"props":363,"children":365},{"className":364},[],[366],{"type":37,"value":367},"*.run.app",{"type":37,"value":369}," ",{"type":32,"tag":52,"props":371,"children":372},{},[373],{"type":37,"value":374},"è considerato di terze parti",{"type":37,"value":376}," — Safari ITP elimina i cookie da questo dominio in 7 giorni. Per questo motivo, un ",{"type":32,"tag":52,"props":378,"children":379},{},[380],{"type":37,"value":381},"subdomain first-party",{"type":37,"value":383}," come ",{"type":32,"tag":60,"props":385,"children":387},{"className":386},[],[388],{"type":37,"value":389},"analytics.tuosito.com",{"type":37,"value":391}," è obbligatorio. Setup di Cloud Load Balancer + certificato SSL gestito:",{"type":32,"tag":393,"props":394,"children":395},"ol",{},[396,409,414,426],{"type":32,"tag":397,"props":398,"children":399},"li",{},[400,402,407],{"type":37,"value":401},"Aggiungi un ",{"type":32,"tag":52,"props":403,"children":404},{},[405],{"type":37,"value":406},"NEG (Network Endpoint Group)",{"type":37,"value":408}," al servizio Cloud Run",{"type":32,"tag":397,"props":410,"children":411},{},[412],{"type":37,"value":413},"Crea un HTTPS Load Balancer, collega il NEG al backend",{"type":32,"tag":397,"props":415,"children":416},{},[417,419,424],{"type":37,"value":418},"Ottieni un certificato SSL gestito da Google per ",{"type":32,"tag":60,"props":420,"children":422},{"className":421},[],[423],{"type":37,"value":389},{"type":37,"value":425}," (può richiedere 48 ore)",{"type":32,"tag":397,"props":427,"children":428},{},[429],{"type":37,"value":430},"Nel DNS, punta il record A al IP del Load Balancer",{"type":32,"tag":33,"props":432,"children":433},{},[434,436,442],{"type":37,"value":435},"Questa configurazione è obbligatoria a livello di produzione. In ambiente di test puoi usare il dominio ",{"type":32,"tag":60,"props":437,"children":439},{"className":438},[],[440],{"type":37,"value":441},"run.app",{"type":37,"value":443},", ma non vedrai gli scenari legati all'ITP.",{"type":32,"tag":40,"props":445,"children":447},{"id":446},"integrazione-meta-conversion-api-strategia-di-deduplicazione-degli-eventi",[448],{"type":37,"value":449},"Integrazione Meta Conversion API: Strategia di Deduplicazione degli Eventi",{"type":32,"tag":33,"props":451,"children":452},{},[453,455,460,462,471],{"type":37,"value":454},"Meta CAPI consente l'invio dell'evento pixel lato server tramite sGTM. Però il ",{"type":32,"tag":52,"props":456,"children":457},{},[458],{"type":37,"value":459},"Meta Pixel lato client",{"type":37,"value":461}," sta già inviando lo stesso evento — se viene contato due volte, l'attribution si rompe. Il metodo ufficiale di deduplicazione di Meta: aggiungi il parametro ",{"type":32,"tag":52,"props":463,"children":464},{},[465],{"type":32,"tag":60,"props":466,"children":468},{"className":467},[],[469],{"type":37,"value":470},"event_id",{"type":37,"value":472}," a ogni evento, invia lo stesso ID sia da client che da server. Meta unisce i duplicati entro 48 ore.",{"type":32,"tag":33,"props":474,"children":475},{},[476],{"type":37,"value":477},"Quando configuri il tag CAPI in sGTM:",{"type":32,"tag":479,"props":480,"children":481},"ul",{},[482,514,532],{"type":32,"tag":397,"props":483,"children":484},{},[485,490,491,497,499,505,506,512],{"type":32,"tag":52,"props":486,"children":487},{},[488],{"type":37,"value":489},"Event Name:",{"type":37,"value":369},{"type":32,"tag":60,"props":492,"children":494},{"className":493},[],[495],{"type":37,"value":496},"PageView",{"type":37,"value":498},", ",{"type":32,"tag":60,"props":500,"children":502},{"className":501},[],[503],{"type":37,"value":504},"Purchase",{"type":37,"value":498},{"type":32,"tag":60,"props":507,"children":509},{"className":508},[],[510],{"type":37,"value":511},"AddToCart",{"type":37,"value":513}," (eventi standard di Meta)",{"type":32,"tag":397,"props":515,"children":516},{},[517,522,524,530],{"type":32,"tag":52,"props":518,"children":519},{},[520],{"type":37,"value":521},"Event ID:",{"type":37,"value":523}," Usa l'hash di ",{"type":32,"tag":60,"props":525,"children":527},{"className":526},[],[528],{"type":37,"value":529},"fbp",{"type":37,"value":531}," cookie da client-side + timestamp",{"type":32,"tag":397,"props":533,"children":534},{},[535,540,541,547,549,555,557,563,564,570],{"type":32,"tag":52,"props":536,"children":537},{},[538],{"type":37,"value":539},"User Data:",{"type":37,"value":369},{"type":32,"tag":60,"props":542,"children":544},{"className":543},[],[545],{"type":37,"value":546},"em",{"type":37,"value":548}," (email con hash), ",{"type":32,"tag":60,"props":550,"children":552},{"className":551},[],[553],{"type":37,"value":554},"ph",{"type":37,"value":556}," (phone con hash), ",{"type":32,"tag":60,"props":558,"children":560},{"className":559},[],[561],{"type":37,"value":562},"client_ip_address",{"type":37,"value":498},{"type":32,"tag":60,"props":565,"children":567},{"className":566},[],[568],{"type":37,"value":569},"client_user_agent",{"type":37,"value":571}," — sGTM può estrarre questi parametri automaticamente dall'HTTP header",{"type":32,"tag":33,"props":573,"children":574},{},[575],{"type":37,"value":576},"Esempio di generazione di Event ID (lato client):",{"type":32,"tag":69,"props":578,"children":582},{"className":579,"code":580,"language":581,"meta":16,"style":16},"language-javascript shiki shiki-themes github-dark","const eventId = CryptoJS.SHA256(\n  fbp + '_' + eventName + '_' + Date.now()\n).toString();\n\nfbq('track', 'Purchase', {\n  value: 99.00,\n  currency: 'USD'\n}, {\n  eventID: eventId\n});\n","javascript",[583],{"type":32,"tag":60,"props":584,"children":585},{"__ignoreMap":16},[586,619,674,692,701,733,751,764,772,780],{"type":32,"tag":79,"props":587,"children":588},{"class":81,"line":82},[589,594,599,604,609,614],{"type":32,"tag":79,"props":590,"children":591},{"style":92},[592],{"type":37,"value":593},"const",{"type":32,"tag":79,"props":595,"children":596},{"style":216},[597],{"type":37,"value":598}," eventId",{"type":32,"tag":79,"props":600,"children":601},{"style":92},[602],{"type":37,"value":603}," =",{"type":32,"tag":79,"props":605,"children":606},{"style":86},[607],{"type":37,"value":608}," CryptoJS.",{"type":32,"tag":79,"props":610,"children":611},{"style":104},[612],{"type":37,"value":613},"SHA256",{"type":32,"tag":79,"props":615,"children":616},{"style":86},[617],{"type":37,"value":618},"(\n",{"type":32,"tag":79,"props":620,"children":621},{"class":81,"line":130},[622,627,632,637,642,647,651,655,659,664,669],{"type":32,"tag":79,"props":623,"children":624},{"style":86},[625],{"type":37,"value":626},"  fbp ",{"type":32,"tag":79,"props":628,"children":629},{"style":92},[630],{"type":37,"value":631},"+",{"type":32,"tag":79,"props":633,"children":634},{"style":98},[635],{"type":37,"value":636}," '_'",{"type":32,"tag":79,"props":638,"children":639},{"style":92},[640],{"type":37,"value":641}," +",{"type":32,"tag":79,"props":643,"children":644},{"style":86},[645],{"type":37,"value":646}," eventName ",{"type":32,"tag":79,"props":648,"children":649},{"style":92},[650],{"type":37,"value":631},{"type":32,"tag":79,"props":652,"children":653},{"style":98},[654],{"type":37,"value":636},{"type":32,"tag":79,"props":656,"children":657},{"style":92},[658],{"type":37,"value":641},{"type":32,"tag":79,"props":660,"children":661},{"style":86},[662],{"type":37,"value":663}," Date.",{"type":32,"tag":79,"props":665,"children":666},{"style":104},[667],{"type":37,"value":668},"now",{"type":32,"tag":79,"props":670,"children":671},{"style":86},[672],{"type":37,"value":673},"()\n",{"type":32,"tag":79,"props":675,"children":676},{"class":81,"line":163},[677,682,687],{"type":32,"tag":79,"props":678,"children":679},{"style":86},[680],{"type":37,"value":681},").",{"type":32,"tag":79,"props":683,"children":684},{"style":104},[685],{"type":37,"value":686},"toString",{"type":32,"tag":79,"props":688,"children":689},{"style":86},[690],{"type":37,"value":691},"();\n",{"type":32,"tag":79,"props":693,"children":694},{"class":81,"line":246},[695],{"type":32,"tag":79,"props":696,"children":698},{"emptyLinePlaceholder":697},true,[699],{"type":37,"value":700},"\n",{"type":32,"tag":79,"props":702,"children":703},{"class":81,"line":259},[704,709,714,719,723,728],{"type":32,"tag":79,"props":705,"children":706},{"style":104},[707],{"type":37,"value":708},"fbq",{"type":32,"tag":79,"props":710,"children":711},{"style":86},[712],{"type":37,"value":713},"(",{"type":32,"tag":79,"props":715,"children":716},{"style":98},[717],{"type":37,"value":718},"'track'",{"type":32,"tag":79,"props":720,"children":721},{"style":86},[722],{"type":37,"value":498},{"type":32,"tag":79,"props":724,"children":725},{"style":98},[726],{"type":37,"value":727},"'Purchase'",{"type":32,"tag":79,"props":729,"children":730},{"style":86},[731],{"type":37,"value":732},", {\n",{"type":32,"tag":79,"props":734,"children":735},{"class":81,"line":272},[736,741,746],{"type":32,"tag":79,"props":737,"children":738},{"style":86},[739],{"type":37,"value":740},"  value: ",{"type":32,"tag":79,"props":742,"children":743},{"style":216},[744],{"type":37,"value":745},"99.00",{"type":32,"tag":79,"props":747,"children":748},{"style":86},[749],{"type":37,"value":750},",\n",{"type":32,"tag":79,"props":752,"children":753},{"class":81,"line":285},[754,759],{"type":32,"tag":79,"props":755,"children":756},{"style":86},[757],{"type":37,"value":758},"  currency: ",{"type":32,"tag":79,"props":760,"children":761},{"style":98},[762],{"type":37,"value":763},"'USD'\n",{"type":32,"tag":79,"props":765,"children":766},{"class":81,"line":298},[767],{"type":32,"tag":79,"props":768,"children":769},{"style":86},[770],{"type":37,"value":771},"}, {\n",{"type":32,"tag":79,"props":773,"children":774},{"class":81,"line":26},[775],{"type":32,"tag":79,"props":776,"children":777},{"style":86},[778],{"type":37,"value":779},"  eventID: eventId\n",{"type":32,"tag":79,"props":781,"children":782},{"class":81,"line":323},[783],{"type":32,"tag":79,"props":784,"children":785},{"style":86},[786],{"type":37,"value":787},"});\n",{"type":32,"tag":33,"props":789,"children":790},{},[791,793,799,801,806],{"type":37,"value":792},"Dal lato di sGTM, passa lo stesso ",{"type":32,"tag":60,"props":794,"children":796},{"className":795},[],[797],{"type":37,"value":798},"eventId",{"type":37,"value":800}," al tag CAPI. Meta deduplica gli eventi con lo stesso ID entro ",{"type":32,"tag":52,"props":802,"children":803},{},[804],{"type":37,"value":805},"48 ore",{"type":37,"value":807},". Gli eventi tardivi ricevuti dopo questo periodo possono essere contati come duplicati.",{"type":32,"tag":33,"props":809,"children":810},{},[811,816,818,823],{"type":32,"tag":52,"props":812,"children":813},{},[814],{"type":37,"value":815},"Protocollo di test:",{"type":37,"value":817}," In Meta Events Manager, vai alla scheda ",{"type":32,"tag":52,"props":819,"children":820},{},[821],{"type":37,"value":822},"Test Events",{"type":37,"value":824},". Quando invii sia l'evento client che server, dovresti vedere il messaggio \"Deduplication Active\", e una sola conversione sotto lo stesso event_id.",{"type":32,"tag":351,"props":826,"children":828},{"id":827},"arricchimento-dei-dati-utente-ip-e-user-agent",[829],{"type":37,"value":830},"Arricchimento dei dati utente: IP e User-Agent",{"type":32,"tag":33,"props":832,"children":833},{},[834,836,841,843,848],{"type":37,"value":835},"La potenza di Meta CAPI dipende dalla ",{"type":32,"tag":52,"props":837,"children":838},{},[839],{"type":37,"value":840},"ricchezza dei parametri di user data",{"type":37,"value":842},". Il Pixel lato client raccoglie questi parametri automaticamente dal browser; lato server devi inviarli manualmente. Usa la variabile ",{"type":32,"tag":52,"props":844,"children":845},{},[846],{"type":37,"value":847},"HTTP Request Headers",{"type":37,"value":849}," di sGTM:",{"type":32,"tag":479,"props":851,"children":852},{},[853,871],{"type":32,"tag":397,"props":854,"children":855},{},[856,861,863,869],{"type":32,"tag":60,"props":857,"children":859},{"className":858},[],[860],{"type":37,"value":562},{"type":37,"value":862}," → ",{"type":32,"tag":60,"props":864,"children":866},{"className":865},[],[867],{"type":37,"value":868},"{{Client IP Address}}",{"type":37,"value":870}," (variabile built-in di sGTM)",{"type":32,"tag":397,"props":872,"children":873},{},[874,879,880,886],{"type":32,"tag":60,"props":875,"children":877},{"className":876},[],[878],{"type":37,"value":569},{"type":37,"value":862},{"type":32,"tag":60,"props":881,"children":883},{"className":882},[],[884],{"type":37,"value":885},"{{User Agent}}",{"type":37,"value":887}," (variabile built-in)",{"type":32,"tag":33,"props":889,"children":890},{},[891,893,898,900,905],{"type":37,"value":892},"Senza questi parametri, l'evento CAPI fornisce un match rate del 40-60% più basso (secondo i dati interni di Meta). Se aggiungi email con hash (",{"type":32,"tag":60,"props":894,"children":896},{"className":895},[],[897],{"type":37,"value":546},{"type":37,"value":899},") e phone con hash (",{"type":32,"tag":60,"props":901,"children":903},{"className":902},[],[904],{"type":37,"value":554},{"type":37,"value":906},"), il match rate sale all'80%. L'hash va fatto con SHA-256, con minuscole + trim:",{"type":32,"tag":69,"props":908,"children":912},{"className":909,"code":910,"language":911,"meta":16,"style":16},"language-python shiki shiki-themes github-dark","import hashlib\n\nemail_hash = hashlib.sha256('user@example.com'.strip().lower().encode()).hexdigest()\n","python",[913],{"type":32,"tag":60,"props":914,"children":915},{"__ignoreMap":16},[916,929,936],{"type":32,"tag":79,"props":917,"children":918},{"class":81,"line":82},[919,924],{"type":32,"tag":79,"props":920,"children":921},{"style":92},[922],{"type":37,"value":923},"import",{"type":32,"tag":79,"props":925,"children":926},{"style":86},[927],{"type":37,"value":928}," hashlib\n",{"type":32,"tag":79,"props":930,"children":931},{"class":81,"line":130},[932],{"type":32,"tag":79,"props":933,"children":934},{"emptyLinePlaceholder":697},[935],{"type":37,"value":700},{"type":32,"tag":79,"props":937,"children":938},{"class":81,"line":163},[939,944,948,953,958],{"type":32,"tag":79,"props":940,"children":941},{"style":86},[942],{"type":37,"value":943},"email_hash ",{"type":32,"tag":79,"props":945,"children":946},{"style":92},[947],{"type":37,"value":141},{"type":32,"tag":79,"props":949,"children":950},{"style":86},[951],{"type":37,"value":952}," hashlib.sha256(",{"type":32,"tag":79,"props":954,"children":955},{"style":98},[956],{"type":37,"value":957},"'user@example.com'",{"type":32,"tag":79,"props":959,"children":960},{"style":86},[961],{"type":37,"value":962},".strip().lower().encode()).hexdigest()\n",{"type":32,"tag":40,"props":964,"children":966},{"id":965},"google-ads-enhanced-conversions-hash-sha-256-e-matching-di-gclid",[967],{"type":37,"value":968},"Google Ads Enhanced Conversions: Hash SHA-256 e Matching di gclid",{"type":32,"tag":33,"props":970,"children":971},{},[972,974,979,981,987],{"type":37,"value":973},"Google Ads Enhanced Conversions richiede l'invio di ",{"type":32,"tag":52,"props":975,"children":976},{},[977],{"type":37,"value":978},"user data con hash",{"type":37,"value":980}," tramite sGTM. La logica è simile a Meta CAPI: hash SHA-256 di PII come email, phone, indirizzo, poi aggiungili al tag di conversion. Google abbina questo dato al ",{"type":32,"tag":60,"props":982,"children":984},{"className":983},[],[985],{"type":37,"value":986},"gclid",{"type":37,"value":988}," e collega la conversione offline.",{"type":32,"tag":33,"props":990,"children":991},{},[992,994,999],{"type":37,"value":993},"Nel tag ",{"type":32,"tag":52,"props":995,"children":996},{},[997],{"type":37,"value":998},"Google Ads Conversion Tracking",{"type":37,"value":1000}," in sGTM:",{"type":32,"tag":479,"props":1002,"children":1003},{},[1004,1014,1039],{"type":32,"tag":397,"props":1005,"children":1006},{},[1007,1009],{"type":37,"value":1008},"Attiva l'opzione ",{"type":32,"tag":52,"props":1010,"children":1011},{},[1012],{"type":37,"value":1013},"Enhanced Conversions",{"type":32,"tag":397,"props":1015,"children":1016},{},[1017,1019,1024,1026,1032,1033],{"type":37,"value":1018},"Nella sezione ",{"type":32,"tag":52,"props":1020,"children":1021},{},[1022],{"type":37,"value":1023},"User Data",{"type":37,"value":1025},", aggiungi le variabili ",{"type":32,"tag":60,"props":1027,"children":1029},{"className":1028},[],[1030],{"type":37,"value":1031},"{{Email Hash}}",{"type":37,"value":498},{"type":32,"tag":60,"props":1034,"children":1036},{"className":1035},[],[1037],{"type":37,"value":1038},"{{Phone Hash}}",{"type":32,"tag":397,"props":1040,"children":1041},{},[1042,1044,1048],{"type":37,"value":1043},"Passa il parametro ",{"type":32,"tag":52,"props":1045,"children":1046},{},[1047],{"type":37,"value":986},{"type":37,"value":1049}," da client-side (dalla query string dell'URL o da un cookie)",{"type":32,"tag":33,"props":1051,"children":1052},{},[1053],{"type":37,"value":1054},"La funzione di hash in JavaScript:",{"type":32,"tag":69,"props":1056,"children":1058},{"className":579,"code":1057,"language":581,"meta":16,"style":16},"async function hashSHA256(value) {\n  const encoder = new TextEncoder();\n  const data = encoder.encode(value.trim().toLowerCase());\n  const hashBuffer = await crypto.subtle.digest('SHA-256', data);\n  const hashArray = Array.from(new Uint8Array(hashBuffer));\n  return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');\n}\n",[1059],{"type":32,"tag":60,"props":1060,"children":1061},{"__ignoreMap":16},[1062,1095,1126,1177,1222,1267,1368],{"type":32,"tag":79,"props":1063,"children":1064},{"class":81,"line":82},[1065,1070,1075,1080,1084,1090],{"type":32,"tag":79,"props":1066,"children":1067},{"style":92},[1068],{"type":37,"value":1069},"async",{"type":32,"tag":79,"props":1071,"children":1072},{"style":92},[1073],{"type":37,"value":1074}," function",{"type":32,"tag":79,"props":1076,"children":1077},{"style":104},[1078],{"type":37,"value":1079}," hashSHA256",{"type":32,"tag":79,"props":1081,"children":1082},{"style":86},[1083],{"type":37,"value":713},{"type":32,"tag":79,"props":1085,"children":1087},{"style":1086},"--shiki-default:#FFAB70",[1088],{"type":37,"value":1089},"value",{"type":32,"tag":79,"props":1091,"children":1092},{"style":86},[1093],{"type":37,"value":1094},") {\n",{"type":32,"tag":79,"props":1096,"children":1097},{"class":81,"line":130},[1098,1103,1108,1112,1117,1122],{"type":32,"tag":79,"props":1099,"children":1100},{"style":92},[1101],{"type":37,"value":1102},"  const",{"type":32,"tag":79,"props":1104,"children":1105},{"style":216},[1106],{"type":37,"value":1107}," encoder",{"type":32,"tag":79,"props":1109,"children":1110},{"style":92},[1111],{"type":37,"value":603},{"type":32,"tag":79,"props":1113,"children":1114},{"style":92},[1115],{"type":37,"value":1116}," new",{"type":32,"tag":79,"props":1118,"children":1119},{"style":104},[1120],{"type":37,"value":1121}," TextEncoder",{"type":32,"tag":79,"props":1123,"children":1124},{"style":86},[1125],{"type":37,"value":691},{"type":32,"tag":79,"props":1127,"children":1128},{"class":81,"line":163},[1129,1133,1138,1142,1147,1152,1157,1162,1167,1172],{"type":32,"tag":79,"props":1130,"children":1131},{"style":92},[1132],{"type":37,"value":1102},{"type":32,"tag":79,"props":1134,"children":1135},{"style":216},[1136],{"type":37,"value":1137}," data",{"type":32,"tag":79,"props":1139,"children":1140},{"style":92},[1141],{"type":37,"value":603},{"type":32,"tag":79,"props":1143,"children":1144},{"style":86},[1145],{"type":37,"value":1146}," encoder.",{"type":32,"tag":79,"props":1148,"children":1149},{"style":104},[1150],{"type":37,"value":1151},"encode",{"type":32,"tag":79,"props":1153,"children":1154},{"style":86},[1155],{"type":37,"value":1156},"(value.",{"type":32,"tag":79,"props":1158,"children":1159},{"style":104},[1160],{"type":37,"value":1161},"trim",{"type":32,"tag":79,"props":1163,"children":1164},{"style":86},[1165],{"type":37,"value":1166},"().",{"type":32,"tag":79,"props":1168,"children":1169},{"style":104},[1170],{"type":37,"value":1171},"toLowerCase",{"type":32,"tag":79,"props":1173,"children":1174},{"style":86},[1175],{"type":37,"value":1176},"());\n",{"type":32,"tag":79,"props":1178,"children":1179},{"class":81,"line":246},[1180,1184,1189,1193,1198,1203,1208,1212,1217],{"type":32,"tag":79,"props":1181,"children":1182},{"style":92},[1183],{"type":37,"value":1102},{"type":32,"tag":79,"props":1185,"children":1186},{"style":216},[1187],{"type":37,"value":1188}," hashBuffer",{"type":32,"tag":79,"props":1190,"children":1191},{"style":92},[1192],{"type":37,"value":603},{"type":32,"tag":79,"props":1194,"children":1195},{"style":92},[1196],{"type":37,"value":1197}," await",{"type":32,"tag":79,"props":1199,"children":1200},{"style":86},[1201],{"type":37,"value":1202}," crypto.subtle.",{"type":32,"tag":79,"props":1204,"children":1205},{"style":104},[1206],{"type":37,"value":1207},"digest",{"type":32,"tag":79,"props":1209,"children":1210},{"style":86},[1211],{"type":37,"value":713},{"type":32,"tag":79,"props":1213,"children":1214},{"style":98},[1215],{"type":37,"value":1216},"'SHA-256'",{"type":32,"tag":79,"props":1218,"children":1219},{"style":86},[1220],{"type":37,"value":1221},", data);\n",{"type":32,"tag":79,"props":1223,"children":1224},{"class":81,"line":259},[1225,1229,1234,1238,1243,1248,1252,1257,1262],{"type":32,"tag":79,"props":1226,"children":1227},{"style":92},[1228],{"type":37,"value":1102},{"type":32,"tag":79,"props":1230,"children":1231},{"style":216},[1232],{"type":37,"value":1233}," hashArray",{"type":32,"tag":79,"props":1235,"children":1236},{"style":92},[1237],{"type":37,"value":603},{"type":32,"tag":79,"props":1239,"children":1240},{"style":86},[1241],{"type":37,"value":1242}," Array.",{"type":32,"tag":79,"props":1244,"children":1245},{"style":104},[1246],{"type":37,"value":1247},"from",{"type":32,"tag":79,"props":1249,"children":1250},{"style":86},[1251],{"type":37,"value":713},{"type":32,"tag":79,"props":1253,"children":1254},{"style":92},[1255],{"type":37,"value":1256},"new",{"type":32,"tag":79,"props":1258,"children":1259},{"style":104},[1260],{"type":37,"value":1261}," Uint8Array",{"type":32,"tag":79,"props":1263,"children":1264},{"style":86},[1265],{"type":37,"value":1266},"(hashBuffer));\n",{"type":32,"tag":79,"props":1268,"children":1269},{"class":81,"line":272},[1270,1275,1280,1285,1289,1294,1299,1304,1308,1312,1317,1321,1326,1330,1335,1339,1344,1349,1354,1358,1363],{"type":32,"tag":79,"props":1271,"children":1272},{"style":92},[1273],{"type":37,"value":1274},"  return",{"type":32,"tag":79,"props":1276,"children":1277},{"style":86},[1278],{"type":37,"value":1279}," hashArray.",{"type":32,"tag":79,"props":1281,"children":1282},{"style":104},[1283],{"type":37,"value":1284},"map",{"type":32,"tag":79,"props":1286,"children":1287},{"style":86},[1288],{"type":37,"value":713},{"type":32,"tag":79,"props":1290,"children":1291},{"style":1086},[1292],{"type":37,"value":1293},"b",{"type":32,"tag":79,"props":1295,"children":1296},{"style":92},[1297],{"type":37,"value":1298}," =>",{"type":32,"tag":79,"props":1300,"children":1301},{"style":86},[1302],{"type":37,"value":1303}," b.",{"type":32,"tag":79,"props":1305,"children":1306},{"style":104},[1307],{"type":37,"value":686},{"type":32,"tag":79,"props":1309,"children":1310},{"style":86},[1311],{"type":37,"value":713},{"type":32,"tag":79,"props":1313,"children":1314},{"style":216},[1315],{"type":37,"value":1316},"16",{"type":32,"tag":79,"props":1318,"children":1319},{"style":86},[1320],{"type":37,"value":681},{"type":32,"tag":79,"props":1322,"children":1323},{"style":104},[1324],{"type":37,"value":1325},"padStart",{"type":32,"tag":79,"props":1327,"children":1328},{"style":86},[1329],{"type":37,"value":713},{"type":32,"tag":79,"props":1331,"children":1332},{"style":216},[1333],{"type":37,"value":1334},"2",{"type":32,"tag":79,"props":1336,"children":1337},{"style":86},[1338],{"type":37,"value":498},{"type":32,"tag":79,"props":1340,"children":1341},{"style":98},[1342],{"type":37,"value":1343},"'0'",{"type":32,"tag":79,"props":1345,"children":1346},{"style":86},[1347],{"type":37,"value":1348},")).",{"type":32,"tag":79,"props":1350,"children":1351},{"style":104},[1352],{"type":37,"value":1353},"join",{"type":32,"tag":79,"props":1355,"children":1356},{"style":86},[1357],{"type":37,"value":713},{"type":32,"tag":79,"props":1359,"children":1360},{"style":98},[1361],{"type":37,"value":1362},"''",{"type":32,"tag":79,"props":1364,"children":1365},{"style":86},[1366],{"type":37,"value":1367},");\n",{"type":32,"tag":79,"props":1369,"children":1370},{"class":81,"line":285},[1371],{"type":32,"tag":79,"props":1372,"children":1373},{"style":86},[1374],{"type":37,"value":1375},"}\n",{"type":32,"tag":33,"props":1377,"children":1378},{},[1379,1381,1387,1389,1394],{"type":37,"value":1380},"Lato client, passa questo hash via ",{"type":32,"tag":60,"props":1382,"children":1384},{"className":1383},[],[1385],{"type":37,"value":1386},"dataLayer.push()",{"type":37,"value":1388},", sGTM lo cattura come variabile e lo invia al tag di Google Ads. ",{"type":32,"tag":52,"props":1390,"children":1391},{},[1392],{"type":37,"value":1393},"Critico:",{"type":37,"value":1395}," L'hash va fatto lato client (privacy — il testo in chiaro non deve andare al server) OPPURE se lo fai in sGTM, disabilita la registrazione.",{"type":32,"tag":33,"props":1397,"children":1398},{},[1399,1404,1406,1412,1414,1420,1422,1428],{"type":32,"tag":52,"props":1400,"children":1401},{},[1402],{"type":37,"value":1403},"Connessione con Consent Mode v2:",{"type":37,"value":1405}," Se ",{"type":32,"tag":60,"props":1407,"children":1409},{"className":1408},[],[1410],{"type":37,"value":1411},"ad_user_data",{"type":37,"value":1413}," e ",{"type":32,"tag":60,"props":1415,"children":1417},{"className":1416},[],[1418],{"type":37,"value":1419},"ad_personalization",{"type":37,"value":1421}," non sono stati consentiti, anche Enhanced Conversions non funzionerà. Devi inviare i segnali di consenso a sGTM tramite l'evento ",{"type":32,"tag":60,"props":1423,"children":1425},{"className":1424},[],[1426],{"type":37,"value":1427},"consent",{"type":37,"value":1429}," nel dataLayer.",{"type":32,"tag":40,"props":1431,"children":1433},{"id":1432},"deduplicazione-degli-eventi-invio-parallelo-lato-client-server",[1434],{"type":37,"value":1435},"Deduplicazione degli eventi: Invio parallelo lato client + server",{"type":32,"tag":33,"props":1437,"children":1438},{},[1439,1441,1446,1448,1453],{"type":37,"value":1440},"In alcuni scenari, sia il tag lato client che quello lato server vengono attivati — per esempio, su Safari il tag lato client funziona, MA l'ITP elimina il cookie in 7 giorni, e nel frattempo il lato server continua a funzionare. C'è un rischio di evento duplicato. Soluzione: usare un ",{"type":32,"tag":52,"props":1442,"children":1443},{},[1444],{"type":37,"value":1445},"unique event_id",{"type":37,"value":1447}," (Meta) o ",{"type":32,"tag":52,"props":1449,"children":1450},{},[1451],{"type":37,"value":1452},"transaction_id",{"type":37,"value":1454}," (Google Analytics 4).",{"type":32,"tag":33,"props":1456,"children":1457},{},[1458],{"type":37,"value":1459},"Deduplicazione in GA4:",{"type":32,"tag":69,"props":1461,"children":1463},{"className":579,"code":1462,"language":581,"meta":16,"style":16},"gtag('event', 'purchase', {\n  transaction_id: 'ORDER_12345', \u002F\u002F univoco per ordine\n  value: 99.00,\n  currency: 'USD'\n});\n",[1464],{"type":32,"tag":60,"props":1465,"children":1466},{"__ignoreMap":16},[1467,1497,1520,1535,1546],{"type":32,"tag":79,"props":1468,"children":1469},{"class":81,"line":82},[1470,1475,1479,1484,1488,1493],{"type":32,"tag":79,"props":1471,"children":1472},{"style":104},[1473],{"type":37,"value":1474},"gtag",{"type":32,"tag":79,"props":1476,"children":1477},{"style":86},[1478],{"type":37,"value":713},{"type":32,"tag":79,"props":1480,"children":1481},{"style":98},[1482],{"type":37,"value":1483},"'event'",{"type":32,"tag":79,"props":1485,"children":1486},{"style":86},[1487],{"type":37,"value":498},{"type":32,"tag":79,"props":1489,"children":1490},{"style":98},[1491],{"type":37,"value":1492},"'purchase'",{"type":32,"tag":79,"props":1494,"children":1495},{"style":86},[1496],{"type":37,"value":732},{"type":32,"tag":79,"props":1498,"children":1499},{"class":81,"line":130},[1500,1505,1510,1514],{"type":32,"tag":79,"props":1501,"children":1502},{"style":86},[1503],{"type":37,"value":1504},"  transaction_id: ",{"type":32,"tag":79,"props":1506,"children":1507},{"style":98},[1508],{"type":37,"value":1509},"'ORDER_12345'",{"type":32,"tag":79,"props":1511,"children":1512},{"style":86},[1513],{"type":37,"value":498},{"type":32,"tag":79,"props":1515,"children":1517},{"style":1516},"--shiki-default:#6A737D",[1518],{"type":37,"value":1519},"\u002F\u002F univoco per ordine\n",{"type":32,"tag":79,"props":1521,"children":1522},{"class":81,"line":163},[1523,1527,1531],{"type":32,"tag":79,"props":1524,"children":1525},{"style":86},[1526],{"type":37,"value":740},{"type":32,"tag":79,"props":1528,"children":1529},{"style":216},[1530],{"type":37,"value":745},{"type":32,"tag":79,"props":1532,"children":1533},{"style":86},[1534],{"type":37,"value":750},{"type":32,"tag":79,"props":1536,"children":1537},{"class":81,"line":246},[1538,1542],{"type":32,"tag":79,"props":1539,"children":1540},{"style":86},[1541],{"type":37,"value":758},{"type":32,"tag":79,"props":1543,"children":1544},{"style":98},[1545],{"type":37,"value":763},{"type":32,"tag":79,"props":1547,"children":1548},{"class":81,"line":259},[1549],{"type":32,"tag":79,"props":1550,"children":1551},{"style":86},[1552],{"type":37,"value":787},{"type":32,"tag":33,"props":1554,"children":1555},{},[1556,1558,1563],{"type":37,"value":1557},"Se invii lo stesso ",{"type":32,"tag":60,"props":1559,"children":1561},{"className":1560},[],[1562],{"type":37,"value":1452},{"type":37,"value":1564}," sia dal gtag.js lato client che da sGTM, il backend di GA4 pulisce il duplicato (finestra di 48 ore).",{"type":32,"tag":33,"props":1566,"children":1567},{},[1568,1573,1575,1580],{"type":32,"tag":52,"props":1569,"children":1570},{},[1571],{"type":37,"value":1572},"Gestione dei timeout:",{"type":37,"value":1574}," I tag di sGTM hanno un'impostazione ",{"type":32,"tag":52,"props":1576,"children":1577},{},[1578],{"type":37,"value":1579},"timeout",{"type":37,"value":1581}," (predefinita 2000ms). Se la risposta di CAPI impiega 3-4 secondi, il tag va in timeout e l'evento non viene inviato. In produzione, alza il timeout a 5000ms e monitora. Il timeout della richiesta di Cloud Run (10s) deve essere coerente con il timeout del tag di sGTM.",{"type":32,"tag":40,"props":1583,"children":1585},{"id":1584},"checklist-di-produzione-monitoring-logging-debug",[1586],{"type":37,"value":1587},"Checklist di produzione: Monitoring, logging, debug",{"type":32,"tag":33,"props":1589,"children":1590},{},[1591],{"type":37,"value":1592},"Prima di portare sGTM in produzione:",{"type":32,"tag":393,"props":1594,"children":1595},{},[1596,1606,1621,1637,1662],{"type":32,"tag":397,"props":1597,"children":1598},{},[1599,1604],{"type":32,"tag":52,"props":1600,"children":1601},{},[1602],{"type":37,"value":1603},"Preview Mode:",{"type":37,"value":1605}," Apri Preview nel GTM web, collegati all'URL del container di sGTM, debug gli eventi client nella console",{"type":32,"tag":397,"props":1607,"children":1608},{},[1609,1614,1616],{"type":32,"tag":52,"props":1610,"children":1611},{},[1612],{"type":37,"value":1613},"Test tag firing:",{"type":37,"value":1615}," Per ogni tag (CAPI, Google Ads, GA4), valida con ",{"type":32,"tag":52,"props":1617,"children":1618},{},[1619],{"type":37,"value":1620},"Tag Assistant",{"type":32,"tag":397,"props":1622,"children":1623},{},[1624,1629,1631],{"type":32,"tag":52,"props":1625,"children":1626},{},[1627],{"type":37,"value":1628},"Segnali di consenso:",{"type":37,"value":1630}," Testa i segnali di Consent Mode v2 — verifica quali tag non si attivano quando ",{"type":32,"tag":60,"props":1632,"children":1634},{"className":1633},[],[1635],{"type":37,"value":1636},"ad_storage=denied",{"type":32,"tag":397,"props":1638,"children":1639},{},[1640,1645,1647,1652,1654,1660],{"type":32,"tag":52,"props":1641,"children":1642},{},[1643],{"type":37,"value":1644},"Log export:",{"type":37,"value":1646}," Flussi Cloud Run log a ",{"type":32,"tag":52,"props":1648,"children":1649},{},[1650],{"type":37,"value":1651},"Cloud Logging",{"type":37,"value":1653},", filtro: ",{"type":32,"tag":60,"props":1655,"children":1657},{"className":1656},[],[1658],{"type":37,"value":1659},"resource.type=\"cloud_run_revision\"",{"type":37,"value":1661},", visualizza i payload degli eventi",{"type":32,"tag":397,"props":1663,"children":1664},{},[1665,1670,1672,1678],{"type":32,"tag":52,"props":1666,"children":1667},{},[1668],{"type":37,"value":1669},"Alerting errori:",{"type":37,"value":1671}," In Cloud Monitoring, crea un alert: ",{"type":32,"tag":60,"props":1673,"children":1675},{"className":1674},[],[1676],{"type":37,"value":1677},"http_response_code >= 500",{"type":37,"value":1679},", soglia 10\u002Fmin",{"type":32,"tag":33,"props":1681,"children":1682},{},[1683],{"type":32,"tag":52,"props":1684,"children":1685},{},[1686],{"type":37,"value":1687},"Strumenti di debug:",{"type":32,"tag":479,"props":1689,"children":1690},{},[1691,1709,1732],{"type":32,"tag":397,"props":1692,"children":1693},{},[1694,1699,1701,1707],{"type":32,"tag":52,"props":1695,"children":1696},{},[1697],{"type":37,"value":1698},"sGTM Debug Mode:",{"type":37,"value":1700}," Apri l'URL di preview del container nel browser, aggiungi ",{"type":32,"tag":60,"props":1702,"children":1704},{"className":1703},[],[1705],{"type":37,"value":1706},"gtm_debug=x",{"type":37,"value":1708}," nella query string",{"type":32,"tag":397,"props":1710,"children":1711},{},[1712,1717,1719,1725,1726],{"type":32,"tag":52,"props":1713,"children":1714},{},[1715],{"type":37,"value":1716},"Network Tab:",{"type":37,"value":1718}," Nel DevTools del browser, ispeziona le richieste ",{"type":32,"tag":60,"props":1720,"children":1722},{"className":1721},[],[1723],{"type":37,"value":1724},"\u002Fgtm.js",{"type":37,"value":1413},{"type":32,"tag":60,"props":1727,"children":1729},{"className":1728},[],[1730],{"type":37,"value":1731},"\u002Fr\u002Fcollect",{"type":32,"tag":397,"props":1733,"children":1734},{},[1735,1740],{"type":32,"tag":52,"props":1736,"children":1737},{},[1738],{"type":37,"value":1739},"Meta Event Test:",{"type":37,"value":1741}," Events Manager → Test Events, visualizza gli eventi dell'ultima ora",{"type":32,"tag":33,"props":1743,"children":1744},{},[1745,1750,1752,1758,1760,1765],{"type":32,"tag":52,"props":1746,"children":1747},{},[1748],{"type":37,"value":1749},"Problema comune:",{"type":37,"value":1751}," L'indirizzo IP del client non arriva a sGTM — controlla che Cloud Load Balancer stia passando l'header ",{"type":32,"tag":60,"props":1753,"children":1755},{"className":1754},[],[1756],{"type":37,"value":1757},"X-Forwarded-For",{"type":37,"value":1759},", attiva l'opzione ",{"type":32,"tag":52,"props":1761,"children":1762},{},[1763],{"type":37,"value":1764},"Preserve Client IP",{"type":37,"value":1766},".",{"type":32,"tag":40,"props":1768,"children":1770},{"id":1769},"architettura-dei-dati-connessione-sgtm-bigquery-dbt",[1771],{"type":37,"value":1772},"Architettura dei dati: Connessione sGTM + BigQuery + dbt",{"type":32,"tag":33,"props":1774,"children":1775},{},[1776,1778,1783,1785,1790,1792,1801],{"type":37,"value":1777},"Puoi streamare gli eventi di sGTM direttamente a BigQuery — tramite ",{"type":32,"tag":52,"props":1779,"children":1780},{},[1781],{"type":37,"value":1782},"Firestore",{"type":37,"value":1784}," o ",{"type":32,"tag":52,"props":1786,"children":1787},{},[1788],{"type":37,"value":1789},"Pub\u002FSub",{"type":37,"value":1791},". L'export di GA4 a BigQuery è un batch giornaliero; con sGTM è possibile uno stream real-time. Questa strategia è importante nel contesto dell'",{"type":32,"tag":1793,"props":1794,"children":1798},"a",{"href":1795,"rel":1796},"https:\u002F\u002Fwww.roibase.com.tr\u002Fit\u002Ffirstparty",[1797],"nofollow",[1799],{"type":37,"value":1800},"architettura first-party di misurazione",{"type":37,"value":1802},": dati di evento grezzo → modelli dbt → semantic layer → dashboard.",{"type":32,"tag":33,"props":1804,"children":1805},{},[1806],{"type":37,"value":1807},"Flusso di esempio:",{"type":32,"tag":393,"props":1809,"children":1810},{},[1811,1816,1821,1834],{"type":32,"tag":397,"props":1812,"children":1813},{},[1814],{"type":37,"value":1815},"Tag di sGTM → invia l'evento JSON al topic di Pub\u002FSub",{"type":32,"tag":397,"props":1817,"children":1818},{},[1819],{"type":37,"value":1820},"Job di Dataflow (o Cloud Function) → legge da Pub\u002FSub e scrive a BigQuery",{"type":32,"tag":397,"props":1822,"children":1823},{},[1824,1826,1832],{"type":37,"value":1825},"Modello dbt → unisce gli eventi per ",{"type":32,"tag":60,"props":1827,"children":1829},{"className":1828},[],[1830],{"type":37,"value":1831},"user_id",{"type":37,"value":1833},", applica la logica di sessione",{"type":32,"tag":397,"props":1835,"children":1836},{},[1837],{"type":37,"value":1838},"Looker\u002FMetabase → dashboard basate sulle view di dbt",{"type":32,"tag":33,"props":1840,"children":1841},{},[1842,1844,1849,1851,1857,1858,1863,1864,1869,1871,1876],{"type":37,"value":1843},"Questa architettura è critica anche per la ",{"type":32,"tag":52,"props":1845,"children":1846},{},[1847],{"type":37,"value":1848},"identity resolution",{"type":37,"value":1850},": puoi unire gli identifier da sGTM come ",{"type":32,"tag":60,"props":1852,"children":1854},{"className":1853},[],[1855],{"type":37,"value":1856},"client_id",{"type":37,"value":498},{"type":32,"tag":60,"props":1859,"children":1861},{"className":1860},[],[1862],{"type":37,"value":529},{"type":37,"value":498},{"type":32,"tag":60,"props":1865,"children":1867},{"className":1866},[],[1868],{"type":37,"value":986},{"type":37,"value":1870}," in BigQuery e creare un singolo ",{"type":32,"tag":60,"props":1872,"children":1874},{"className":1873},[],[1875],{"type":37,"value":1831},{"type":37,"value":1877},". Esempio di modello dbt incrementale:",{"type":32,"tag":69,"props":1879,"children":1883},{"className":1880,"code":1881,"language":1882,"meta":16,"style":16},"language-sql shiki shiki-themes github-dark","{{ config(materialized='incremental', unique_key='event_id') }}\n\nSELECT\n  event_id,\n  user_id,\n  client_id,\n  event_timestamp,\n  event_name,\n  event_params\nFROM {{ source('sgtm_events', 'raw_events') }}\n{% if is_incremental() %}\nWHERE event_timestamp > (SELECT MAX(event_timestamp) FROM {{ this }})\n{% endif %}\n","sql",[1884],{"type":32,"tag":60,"props":1885,"children":1886},{"__ignoreMap":16},[1887,1923,1930,1938,1946,1954,1962,1970,1978,1986,2017,2036,2084],{"type":32,"tag":79,"props":1888,"children":1889},{"class":81,"line":82},[1890,1895,1899,1904,1909,1913,1918],{"type":32,"tag":79,"props":1891,"children":1892},{"style":86},[1893],{"type":37,"value":1894},"{{ config(materialized",{"type":32,"tag":79,"props":1896,"children":1897},{"style":92},[1898],{"type":37,"value":141},{"type":32,"tag":79,"props":1900,"children":1901},{"style":98},[1902],{"type":37,"value":1903},"'incremental'",{"type":32,"tag":79,"props":1905,"children":1906},{"style":86},[1907],{"type":37,"value":1908},", unique_key",{"type":32,"tag":79,"props":1910,"children":1911},{"style":92},[1912],{"type":37,"value":141},{"type":32,"tag":79,"props":1914,"children":1915},{"style":98},[1916],{"type":37,"value":1917},"'event_id'",{"type":32,"tag":79,"props":1919,"children":1920},{"style":86},[1921],{"type":37,"value":1922},") }}\n",{"type":32,"tag":79,"props":1924,"children":1925},{"class":81,"line":130},[1926],{"type":32,"tag":79,"props":1927,"children":1928},{"emptyLinePlaceholder":697},[1929],{"type":37,"value":700},{"type":32,"tag":79,"props":1931,"children":1932},{"class":81,"line":163},[1933],{"type":32,"tag":79,"props":1934,"children":1935},{"style":92},[1936],{"type":37,"value":1937},"SELECT\n",{"type":32,"tag":79,"props":1939,"children":1940},{"class":81,"line":246},[1941],{"type":32,"tag":79,"props":1942,"children":1943},{"style":86},[1944],{"type":37,"value":1945},"  event_id,\n",{"type":32,"tag":79,"props":1947,"children":1948},{"class":81,"line":259},[1949],{"type":32,"tag":79,"props":1950,"children":1951},{"style":86},[1952],{"type":37,"value":1953},"  user_id,\n",{"type":32,"tag":79,"props":1955,"children":1956},{"class":81,"line":272},[1957],{"type":32,"tag":79,"props":1958,"children":1959},{"style":86},[1960],{"type":37,"value":1961},"  client_id,\n",{"type":32,"tag":79,"props":1963,"children":1964},{"class":81,"line":285},[1965],{"type":32,"tag":79,"props":1966,"children":1967},{"style":86},[1968],{"type":37,"value":1969},"  event_timestamp,\n",{"type":32,"tag":79,"props":1971,"children":1972},{"class":81,"line":298},[1973],{"type":32,"tag":79,"props":1974,"children":1975},{"style":86},[1976],{"type":37,"value":1977},"  event_name,\n",{"type":32,"tag":79,"props":1979,"children":1980},{"class":81,"line":26},[1981],{"type":32,"tag":79,"props":1982,"children":1983},{"style":86},[1984],{"type":37,"value":1985},"  event_params\n",{"type":32,"tag":79,"props":1987,"children":1988},{"class":81,"line":323},[1989,1994,1999,2004,2008,2013],{"type":32,"tag":79,"props":1990,"children":1991},{"style":92},[1992],{"type":37,"value":1993},"FROM",{"type":32,"tag":79,"props":1995,"children":1996},{"style":86},[1997],{"type":37,"value":1998}," {{ source(",{"type":32,"tag":79,"props":2000,"children":2001},{"style":98},[2002],{"type":37,"value":2003},"'sgtm_events'",{"type":32,"tag":79,"props":2005,"children":2006},{"style":86},[2007],{"type":37,"value":498},{"type":32,"tag":79,"props":2009,"children":2010},{"style":98},[2011],{"type":37,"value":2012},"'raw_events'",{"type":32,"tag":79,"props":2014,"children":2015},{"style":86},[2016],{"type":37,"value":1922},{"type":32,"tag":79,"props":2018,"children":2020},{"class":81,"line":2019},11,[2021,2026,2031],{"type":32,"tag":79,"props":2022,"children":2023},{"style":86},[2024],{"type":37,"value":2025},"{% ",{"type":32,"tag":79,"props":2027,"children":2028},{"style":92},[2029],{"type":37,"value":2030},"if",{"type":32,"tag":79,"props":2032,"children":2033},{"style":86},[2034],{"type":37,"value":2035}," is_incremental() %}\n",{"type":32,"tag":79,"props":2037,"children":2039},{"class":81,"line":2038},12,[2040,2045,2050,2055,2060,2065,2070,2075,2079],{"type":32,"tag":79,"props":2041,"children":2042},{"style":92},[2043],{"type":37,"value":2044},"WHERE",{"type":32,"tag":79,"props":2046,"children":2047},{"style":86},[2048],{"type":37,"value":2049}," event_timestamp ",{"type":32,"tag":79,"props":2051,"children":2052},{"style":92},[2053],{"type":37,"value":2054},">",{"type":32,"tag":79,"props":2056,"children":2057},{"style":86},[2058],{"type":37,"value":2059}," (",{"type":32,"tag":79,"props":2061,"children":2062},{"style":92},[2063],{"type":37,"value":2064},"SELECT",{"type":32,"tag":79,"props":2066,"children":2067},{"style":216},[2068],{"type":37,"value":2069}," MAX",{"type":32,"tag":79,"props":2071,"children":2072},{"style":86},[2073],{"type":37,"value":2074},"(event_timestamp) ",{"type":32,"tag":79,"props":2076,"children":2077},{"style":92},[2078],{"type":37,"value":1993},{"type":32,"tag":79,"props":2080,"children":2081},{"style":86},[2082],{"type":37,"value":2083}," {{ this }})\n",{"type":32,"tag":79,"props":2085,"children":2087},{"class":81,"line":2086},13,[2088],{"type":32,"tag":79,"props":2089,"children":2090},{"style":86},[2091],{"type":37,"value":2092},"{% endif %}\n",{"type":32,"tag":33,"props":2094,"children":2095},{},[2096,2098,2103,2105,2110,2111,2117],{"type":37,"value":2097},"Questa configurazione supporta anche il ",{"type":32,"tag":52,"props":2099,"children":2100},{},[2101],{"type":37,"value":2102},"modello di attribution",{"type":37,"value":2104},": puoi JOIN gli eventi di sGTM a BigQuery tramite ",{"type":32,"tag":60,"props":2106,"children":2108},{"className":2107},[],[2109],{"type":37,"value":986},{"type":37,"value":1413},{"type":32,"tag":60,"props":2112,"children":2114},{"className":2113},[],[2115],{"type":37,"value":2116},"fbclid",{"type":37,"value":2118}," e calcolare l'attribution multi-touch.",{"type":32,"tag":2120,"props":2121,"children":2122},"hr",{},[],{"type":32,"tag":33,"props":2124,"children":2125},{},[2126,2128,2133],{"type":37,"value":2127},"La misurazione lato server non è più un'ottimizzazione opzionale, è un'infrastruttura obbligatoria in un mondo privacy-first. Deploy su Cloud Run, deduplicazione di CAPI, hash Enhanced Conversions, stream a BigQuery — ogni passaggio richiede una decisione tecnica. Inizia in ambiente di test con il dominio ",{"type":32,"tag":60,"props":2129,"children":2131},{"className":2130},[],[2132],{"type":37,"value":441},{"type":37,"value":2134},", prima di andare in produzione configura un dominio personalizzato + SSL, valida i segnali di consenso, attiva il monitoring. sGTM da solo non è la soluzione — deve lavorare in parallelo con i tag lato client, la logica di deduplicazione deve essere solida. Se vuoi salvare l'attribution, la migrazione al server-side measurement è inevitabile, ma il percorso da zero a produzione richiede 4-6 settimane di lavoro di ingegneria.",{"type":32,"tag":2136,"props":2137,"children":2138},"style",{},[2139],{"type":37,"value":2140},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":16,"searchDepth":163,"depth":163,"links":2142},[2143,2146,2149,2150,2151,2152],{"id":42,"depth":130,"text":45,"children":2144},[2145],{"id":353,"depth":163,"text":356},{"id":446,"depth":130,"text":449,"children":2147},[2148],{"id":827,"depth":163,"text":830},{"id":965,"depth":130,"text":968},{"id":1432,"depth":130,"text":1435},{"id":1584,"depth":130,"text":1587},{"id":1769,"depth":130,"text":1772},"markdown","content:it:data:server-side-gtm-conversion-api-production.md","content","it\u002Fdata\u002Fserver-side-gtm-conversion-api-production.md","it\u002Fdata\u002Fserver-side-gtm-conversion-api-production","md",1782050755279]