Install DataPocket on React Router
Updated
Framework mode (Remix) and library mode. pushState navigations are tracked automatically. Sign in and these snippets fill in your site ID and domain. Until then, swap YOUR_SITE_ID and YOUR_DOMAIN with the values from your Install page.
- 1
Framework mode: add the script in app/root.tsx inside <head>:
tsxexport function Layout({ children }: { children: React.ReactNode }) { return ( <html lang="en"> <head> <Meta /> <Links /> <script defer data-site-id="YOUR_SITE_ID" data-domain="YOUR_DOMAIN" src="https://datapocket.vo1d.studio/js/script.js" /> </head> <body>{children}<ScrollRestoration /><Scripts /></body> </html> ); } - 2
Library mode (Vite SPA): paste the tag into index.html <head>. Using HashRouter? Load script.hash.js instead:
html<script defer data-site-id="YOUR_SITE_ID" data-domain="YOUR_DOMAIN" src="https://datapocket.vo1d.studio/js/script.js" ></script>
Revenue attribution
- 1
Pass the visitor cookie to Stripe Checkout so each sale is attributed to the channel that brought the buyer:
jsconst session = await stripe.checkout.sessions.create({ // …your line_items, mode, success_url… metadata: { datapocket_visitor_id: req.cookies.dp_vid, datapocket_session_id: req.cookies.dp_sid, }, }); - 2
Using another payment provider? Send payments from your backend (create an API key in Settings):
bashcurl -X POST https://datapocket.vo1d.studio/api/v1/payments \ -H "Authorization: Bearer dpk_…" \ -H "Content-Type: application/json" \ -d '{"amount": 29.99, "currency": "USD", "transaction_id": "order_123", "visitor_id": "<dp_vid cookie>"}'
Related guides
Vue.jsVue 3 + Vue Router, Nuxt, Vite. History-mode routing is tracked automatically.
JavaScript appsReact, Vue, Svelte or Angular: the script tag with typed calls, plus server-side payments and goals over HTTP.
ExpressServe the script and forward events from your Express server.
FastAPIAsync proxy with httpx.
- AI crawler trackingSee when ChatGPT, Claude and Perplexity read your pages. One server-side call.
- All install guides25 platforms, code and no-code.