Rastreie cliques de anúncios que direcionam pro WhatsApp — atribua conversas ao criativo que gerou o clique.
Muitos funis do mercado brasileiro terminam num link wa.me/…?text=… — o cliente clica no anúncio, cai no WhatsApp, conversa com o vendedor, fecha a venda. Sem tracking, você perde a atribuição — o painel do TikTok não sabe que aquele clique virou venda.O script whatsapp.js resolve isso propagando o LeadId no texto pré-preenchido da mensagem.
Instalação
Cole no <head> da landing/página que tem o botão WhatsApp:
Basta extrair o LeadId do marcador [ref:…] que veio na primeira mensagem do cliente.
Se você usa um CRM tipo Chatwoot ou um bot, escreva uma regra que capture o [ref:...] da primeira mensagem e grave como atributo do contato. Assim, quando a venda for fechada, é só ler esse atributo.
Alternativa sem WhatsApp Web API
Se você não tem backend/bot e mesmo assim quer atribuição, use um encurtador tipo Bit.ly ou seu próprio redirecionador que registra o clique. Nesse caso, chame diretamente:
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"xTracky Docs","description":"Documentação oficial da xTracky — rastreamento de conversões, tracking multi-plataforma e integração com 90+ gateways de pagamento.","colors":{"primary":"#06A7CA","light":"#23CFFF","dark":"#05C3DD"},"logo":{"light":"https://mintcdn.com/x-tracky/N7ze3qaeJTbYgYJI/logo/light.svg?fit=max\u0026auto=format\u0026n=N7ze3qaeJTbYgYJI\u0026q=85\u0026s=ca5b4b95c623a5b6d65a93aeb98ed863","dark":"https://mintcdn.com/x-tracky/N7ze3qaeJTbYgYJI/logo/dark.svg?fit=max\u0026auto=format\u0026n=N7ze3qaeJTbYgYJI\u0026q=85\u0026s=a866403eb8bac9f657d7580f317a03c1","href":"https://docs.xtracky.com"},"favicon":"https://mintcdn.com/x-tracky/N7ze3qaeJTbYgYJI/favicon.png?fit=max\u0026auto=format\u0026n=N7ze3qaeJTbYgYJI\u0026q=85\u0026s=b45f7c3a7b12bab7e8ab3a01b3c1255c","appearance":{"default":"dark","strict":false},"background":{"color":{"light":"#FAFAFA","dark":"#0D1112"}},"navbar":{"links":[{"href":"mailto:suporte@xtracky.com","label":"Suporte"}],"primary":{"type":"button","label":"Acessar Painel","href":"https://app.xtracky.com"}},"footer":{"socials":{"instagram":"https://instagram.com/x.tracky_","website":"https://xtracky.com"},"links":[{"header":"Produto","items":[{"label":"Site","href":"https://xtracky.com"},{"label":"Painel","href":"https://app.xtracky.com"},{"label":"Planos","href":"https://xtracky.com/"}]},{"header":"Recursos","items":[{"label":"Documentação","href":"https://docs.xtracky.com"},{"label":"Instagram","href":"https://instagram.com/x.tracky_"}]}]},"search":{"prompt":"Buscar na documentação..."},"seo":{"metatags":{"og:title":"xTracky Docs — Rastreamento de conversões e tracking multi-plataforma","og:description":"Integre a xTracky em 5 minutos. Rastreie vendas via Kwai, TikTok, Meta e Google Ads com sistema de leads inteligente.","twitter:card":"summary_large_image"},"indexing":"navigable"},"fonts":{"heading":{"family":"Inter"},"body":{"family":"Inter"}},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"Painel xTracky","icon":"chart-line","href":"https://app.xtracky.com"},{"anchor":"Status","icon":"signal-bars","href":"https://status.xtracky.com"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"x-tracky","hasAudioNarration":false,"actualSubdomain":"x-tracky","customDomains":["docs.xtracky.com"],"gitSource":{"type":"github","owner":"xtracky","repo":"xtracky","deployBranch":"main","contentDirectory":"doc","isPrivate":true,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6a98bf2d1a3978f98e37b01d","clientVersion":"0.0.4286","searchFilterCounts":[{"language":"default","tag":"Documentação","count":17},{"language":"default","tag":"Scripts","count":7},{"language":"default","tag":"Conceitos","count":5},{"language":"default","tag":"API Reference","count":3},{"language":"default","tag":"Endpoints","count":2},{"language":"default","tag":"Comece Aqui","count":2},{"language":"default","tag":"Plataformas","count":2},{"language":"default","tag":"Visão Geral","count":1},{"language":"default","tag":"Introdução","count":1}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"scripts/whatsapp","slug":"/scripts/whatsapp","pageMetadata":{"title":"WhatsApp","description":"Rastreie cliques de anúncios que direcionam pro WhatsApp — atribua conversas ao criativo que gerou o clique.","href":"/scripts/whatsapp"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Rastreie cliques de anúncios que direcionam pro WhatsApp — atribua conversas ao criativo que gerou o clique.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,..._provideComponents(),...props.components},{CodeBlock,Heading,Tip}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Tip)_missingMdxReference(`Tip`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`Muitos funis do mercado brasileiro terminam num link `,_jsx(_components.code,{children:`wa.me/…?text=…`}),` — o cliente clica no anúncio, cai no WhatsApp, conversa com o vendedor, fecha a venda. Sem tracking, você `,_jsx(_components.strong,{children:`perde a atribuição`}),` — o painel do TikTok não sabe que aquele clique virou venda.`]}),`\n`,_jsxs(_components.p,{children:[`O script `,_jsx(_components.code,{children:`whatsapp.js`}),` resolve isso propagando o `,_jsx(_components.code,{children:`LeadId`}),` no texto pré-preenchido da mensagem.`]}),`\n`,_jsx(Heading,{level:`2`,id:`instalação`,children:`Instalação`}),`\n`,_jsxs(_components.p,{children:[`Cole no `,_jsx(_components.code,{children:`\u003chead>`}),` da landing/página que tem o botão WhatsApp:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`html`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`html`,children:_jsxs(_components.code,{language:`html`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`script`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` src`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://cdn.xtracky.com/scripts/whatsapp.js\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` data-token`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SEU_PRODUCT_ID\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`script`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`como-funciona`,children:`Como funciona`}),`\n`,_jsx(_components.p,{children:`Ao carregar a página, o script:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Gera (ou recupera) o `,_jsx(_components.code,{children:`LeadId`}),` — igual ao V2`]}),`\n`,_jsxs(_components.li,{children:[`Encontra todos os links `,_jsx(_components.code,{children:`\u003ca href=\"https://wa.me/...\">`}),` da página`]}),`\n`,_jsxs(_components.li,{children:[`Anexa o `,_jsx(_components.code,{children:`LeadId`}),` no parâmetro `,_jsx(_components.code,{children:`text=`}),` da URL`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Antes`}),` (o que você escreve no HTML):`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`html`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`html`,children:_jsxs(_components.code,{language:`html`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`a`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` href`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://wa.me/5511999999999?text=Ol%C3%A1%2C%20quero%20saber%20mais\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Falar no WhatsApp`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`a`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Depois`}),` (o que o cliente vê ao clicar):`]}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`https://wa.me/5511999999999?text=Olá,%20quero%20saber%20mais%20%5Bref:TT-1763007625226-yn4xita3qylwh%5D`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`O `,_jsx(_components.code,{children:`[ref:XXXX]`}),` é o marcador que sua equipe de vendas (ou seu bot) usa pra registrar a atribuição de volta na xTracky.`]}),`\n`,_jsx(Heading,{level:`2`,id:`registrando-a-venda`,children:`Registrando a venda`}),`\n`,_jsx(_components.p,{children:`Quando o cliente fechar a venda pelo WhatsApp, seu backend (ou operador) chama a API:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` POST`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://api.xtracky.com/api/integrations/api`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"orderId\": \"WPP_ORDER_456\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"amount\": 49700,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"status\": \"paid\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"utm_source\": \"TT-1763007625226-yn4xita3qylwh\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"leadName\": \"Cliente WhatsApp\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"leadPhone\": \"+5511988887777\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }'`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Basta extrair o `,_jsx(_components.code,{children:`LeadId`}),` do marcador `,_jsx(_components.code,{children:`[ref:…]`}),` que veio na primeira mensagem do cliente.`]}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`Se você usa um CRM tipo Chatwoot ou um bot, escreva uma regra que capture o `,_jsx(_components.code,{children:`[ref:...]`}),` da primeira mensagem e grave como atributo do contato. Assim, quando a venda for fechada, é só ler esse atributo.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`alternativa-sem-whatsapp-web-api`,children:`Alternativa sem WhatsApp Web API`}),`\n`,_jsx(_components.p,{children:`Se você não tem backend/bot e mesmo assim quer atribuição, use um encurtador tipo Bit.ly ou seu próprio redirecionador que registra o clique. Nesse caso, chame diretamente:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`12`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`12`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`document`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`querySelector`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'a[href*=\"wa.me\"]'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`).`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`addEventListener`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'click'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, () `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'https://api.xtracky.com/api/integrations/api'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` method:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'POST'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` headers:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'Content-Type'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'application/json'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` body:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` JSON`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`stringify`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` orderId:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `WPP_CLICK_\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Date`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`now`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`()`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` amount:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` status:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'initiate_checkout'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` utm_source:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`xtracky`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`?.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getLeadId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }),`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"WhatsApp","description":"Rastreie cliques de anúncios que direcionam pro WhatsApp — atribua conversas ao criativo que gerou o clique.","href":"/scripts/whatsapp"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Instalação","slug":"instalação","depth":2,"children":[]},{"title":"Como funciona","slug":"como-funciona","depth":2,"children":[]},{"title":"Registrando a venda","slug":"registrando-a-venda","depth":2,"children":[]},{"title":"Alternativa sem WhatsApp Web API","slug":"alternativa-sem-whatsapp-web-api","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"dynamicCss":".\\[ref\\:\\.\\.\\.\\] {\n ref: ...\n}\n.\\[ref\\:XXXX\\] {\n ref: XXXX\n}\n.\\[ref\\:\\2026\\] {\n ref: …\n}","subdomain":"x-tracky","siteName":"xTracky Docs","title":"xTracky Docs — Rastreamento de conversões e tracking multi-plataforma","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-09-02T06:13:28.078Z","originalFileLocation":"scripts/whatsapp.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"dark\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Rastreie cliques de anúncios que direcionam pro WhatsApp — atribua conversas ao criativo que gerou o clique.\">\u003cmeta data-mint-head name=\"application-name\" content=\"xTracky Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/x-tracky/NTlwJ5En4t0y5wnr/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/x-tracky/NTlwJ5En4t0y5wnr/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/x-tracky/NTlwJ5En4t0y5wnr/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/x-tracky/NTlwJ5En4t0y5wnr/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/x-tracky/NTlwJ5En4t0y5wnr/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/x-tracky/NTlwJ5En4t0y5wnr/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/x-tracky/NTlwJ5En4t0y5wnr/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/x-tracky/NTlwJ5En4t0y5wnr/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/x-tracky/NTlwJ5En4t0y5wnr/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"xTracky Docs — Rastreamento de conversões e tracking multi-plataforma\">\u003cmeta data-mint-head property=\"og:description\" content=\"Integre a xTracky em 5 minutos. Rastreie vendas via Kwai, TikTok, Meta e Google Ads com sistema de leads inteligente.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"xTracky Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.xtracky.com/scripts/whatsapp\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://x-tracky.mintlify.site/_mintlify/api/og/v2?division=Scripts\u0026amp;title=WhatsApp\u0026amp;description=Rastreie+cliques+de+an%C3%BAncios+que+direcionam+pro+WhatsApp+%E2%80%94+atribua+conversas+ao+criativo+que+gerou+o+clique.\u0026amp;theme=ddea58afdc30a1126fc48a1a\u0026amp;signature=f3c95116a206feabce665a9ba6fecda2ff226d6926a2bf80c7463259eaf07f57\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"xTracky Docs — Rastreamento de conversões e tracking multi-plataforma\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Integre a xTracky em 5 minutos. Rastreie vendas via Kwai, TikTok, Meta e Google Ads com sistema de leads inteligente.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://x-tracky.mintlify.site/_mintlify/api/og/v2?division=Scripts\u0026amp;title=WhatsApp\u0026amp;description=Rastreie+cliques+de+an%C3%BAncios+que+direcionam+pro+WhatsApp+%E2%80%94+atribua+conversas+ao+criativo+que+gerou+o+clique.\u0026amp;theme=ddea58afdc30a1126fc48a1a\u0026amp;signature=f3c95116a206feabce665a9ba6fecda2ff226d6926a2bf80c7463259eaf07f57\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/x-tracky/NTlwJ5En4t0y5wnr/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"xTracky Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#06A7CA\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.xtracky.com/scripts/whatsapp\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/scripts/whatsapp.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.xtracky.com/#organization\",\"name\":\"xTracky Docs\",\"url\":\"https://docs.xtracky.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/x-tracky/N7ze3qaeJTbYgYJI/logo/light.svg?fit=max\u0026auto=format\u0026n=N7ze3qaeJTbYgYJI\u0026q=85\u0026s=ca5b4b95c623a5b6d65a93aeb98ed863\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.xtracky.com#website\",\"name\":\"xTracky Docs\",\"url\":\"https://docs.xtracky.com\",\"publisher\":{\"@id\":\"https://docs.xtracky.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.xtracky.com/scripts/whatsapp#webpage\",\"url\":\"https://docs.xtracky.com/scripts/whatsapp\",\"name\":\"WhatsApp\",\"description\":\"Rastreie cliques de anúncios que direcionam pro WhatsApp — atribua conversas ao criativo que gerou o clique.\",\"dateModified\":\"2026-09-02T06:13:28.078Z\",\"isPartOf\":{\"@id\":\"https://docs.xtracky.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.xtracky.com/scripts/whatsapp#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.xtracky.com/scripts/whatsapp#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Scripts\",\"item\":\"https://docs.xtracky.com/scripts/visao-geral\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WhatsApp\",\"item\":\"https://docs.xtracky.com/scripts/whatsapp\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.xtracky.com/scripts/whatsapp#article\",\"headline\":\"WhatsApp\",\"name\":\"WhatsApp\",\"description\":\"Rastreie cliques de anúncios que direcionam pro WhatsApp — atribua conversas ao criativo que gerou o clique.\",\"url\":\"https://docs.xtracky.com/scripts/whatsapp\",\"mainEntityOfPage\":{\"@id\":\"https://docs.xtracky.com/scripts/whatsapp#webpage\"},\"dateModified\":\"2026-09-02T06:13:28.078Z\",\"publisher\":{\"@id\":\"https://docs.xtracky.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.xtracky.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"xTracky Docs\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"xTracky Docs\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/scripts/whatsapp.md","siteName":"xTracky Docs","nav":{"global":{"anchors":[{"anchor":"Painel xTracky","icon":"chart-line","href":"https://app.xtracky.com"},{"anchor":"Status","icon":"signal-bars","href":"https://status.xtracky.com"}]},"tabs":[{"tab":"Documentação","groups":[{"group":"Introdução","pages":[{"title":"Introdução","href":"/introduction"}]},{"group":"Comece Aqui","pages":[{"title":"Instalação do Script","href":"/comece-aqui/instalacao"},{"title":"Primeira conversão","href":"/comece-aqui/primeira-conversao"}]},{"group":"Conceitos","pages":[{"title":"Como funciona","href":"/conceitos/como-funciona"},{"title":"Sistema de Leads (V2)","href":"/conceitos/leads-e-plataformas"},{"title":"Status de Pagamento","href":"/conceitos/status-pagamento"},{"title":"Deduplicação","href":"/conceitos/deduplicacao"},{"title":"SPAs (Single Page Applications)","href":"/conceitos/spa"}]},{"group":"Scripts","pages":[{"title":"Visão geral","href":"/scripts/visao-geral"},{"title":"Lead System (V2)","href":"/scripts/lead-system"},{"title":"UTM Handler (V1)","href":"/scripts/utm-handler"},{"title":"Shopify","description":"Script otimizado para lojas Shopify — captura UTMs e mantém no checkout mesmo com domínios diferentes.","href":"/scripts/shopify"},{"title":"WhatsApp","href":"/scripts/whatsapp"},{"title":"Botão de checkout automático","description":"Adicione data-xtracky-checkout ao botão e o evento InitiateCheckout dispara sozinho — sem tocar em código.","href":"/scripts/botao-checkout"},{"title":"Evitar URL Scan","href":"/scripts/avoid-urlscan"}]},{"group":"Plataformas","pages":[{"title":"Plataformas integradas","href":"/plataformas/lista"},{"title":"Configurar webhook","href":"/plataformas/configurar-webhook"}]}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/api-reference/introducao"}]}]},"basePath":"","title":"xTracky Docs — Rastreamento de conversões e tracking multi-plataforma","deploymentId":"dpl_G6E2ur2Zjq51xGTVZPSFXsWoTxCu","buildId":"dpl_G6E2ur2Zjq51xGTVZPSFXsWoTxCu","dynamics":[],"chunks":[]}