___INFO___ { "type": "TAG", "id": "cvt_temp_public_id", "version": 1, "securityGroups": [], "displayName": "DataNostro — Meta Conversions API", "description": "Server-side Meta CAPI tag with event_id deduplication. Hashes email + phone before send. Pixel ID + access token come from variables.", "containerContexts": ["SERVER"] } ___TEMPLATE_PARAMETERS___ [ {"type": "TEXT","name": "pixel_id","displayName": "Pixel ID","simpleValueType": true,"valueValidators": [{"type":"NON_EMPTY"}]}, {"type": "TEXT","name": "access_token","displayName": "Access Token","simpleValueType": true,"valueValidators": [{"type":"NON_EMPTY"}]}, {"type": "TEXT","name": "test_event_code","displayName": "Test event code (optional)","simpleValueType": true}, {"type": "TEXT","name": "event_name","displayName": "Event name","simpleValueType": true,"defaultValue": "Purchase"} ] ___SANDBOXED_JS_FOR_SERVER___ const sendHttpRequest = require("sendHttpRequest"); const getEventData = require("getEventData"); const sha256Sync = require("sha256Sync"); const getTimestampMillis = require("getTimestampMillis"); const url = "https://graph.facebook.com/v19.0/" + data.pixel_id + "/events?access_token=" + data.access_token; const eventData = { event_name: data.event_name, event_time: Math.floor(getTimestampMillis() / 1000), event_id: getEventData("event_id") || "", event_source_url: getEventData("page_location") || "", action_source: "website", user_data: { em: getEventData("user_data.email_address") ? [sha256Sync(getEventData("user_data.email_address").toLowerCase().trim(), {outputEncoding: "hex"})] : [], ph: getEventData("user_data.phone_number") ? [sha256Sync(getEventData("user_data.phone_number"), {outputEncoding: "hex"})] : [], fbc: getEventData("user_data.fbc") || "", fbp: getEventData("user_data.fbp") || "" }, custom_data: { currency: getEventData("currency") || "CZK", value: getEventData("value") || 0 } }; const body = {data: [eventData]}; if (data.test_event_code) body.test_event_code = data.test_event_code; sendHttpRequest(url, {method: "POST", headers: {"Content-Type": "application/json"}}, JSON.stringify(body)); data.gtmOnSuccess(); ___SERVER_PERMISSIONS___ [ {"instance": {"key": {"publicId": "send_http"}, "param": [{"key": "allowedUrls","value": {"type": 1,"string": "specific"}},{"key": "urls","value": {"type": 2,"listItem": [{"type": 1,"string": "https://graph.facebook.com/*"}]}}]}} ] ___TESTS___ scenarios: [] ___NOTES___ Hashes email + phone with SHA-256 before send (Meta requirement). Pass event_id from the client tag too — Meta deduplicates Pixel + CAPI events that share event_id.