Your data

Tracking your website

Add the tracking code to your website to see what your contacts do there.

The tracking code is a small script on your website. It records what your contacts do there, which you can use in segments, flows and conversions. Each website has its own code.

Add it to your website

  • In the app, go to Settings → Tracking and choose Connect a website.
  • Enter your website’s address, like shop.com. Turn on Include subdomains if the code should also work on blog.shop.com and other subdomains. Another domain is another website.
  • Copy the install code and paste it just before </head> on every page of your site (in most site builders: Settings → Custom code → Header).
  • Open your site. The website’s status in Settings → Tracking turns Connected after the first visit.
The install code (yours has your own key)
<script async src="https://yousendit.io/api/client/ysi.js?key=ypk_…"></script>
The code only works on the website it was made for. On any other domain it records nothing.

What it records

  • Active on Site: every page visit, at most once every 30 minutes per visitor. Nothing to add.
  • Viewed Product and Added to Cart: when your pages send them, as below.
  • Conversions from Visited a page and Website code.
On a product page, and when something is added to the cart
<script>
  window.ysi = window.ysi || [];
  ysi.push(["track", "Viewed Product", { product_id: "123", title: "Mug", url: "https://shop.com/mug", price: "12.50" }]);
  ysi.push(["track", "Added to Cart", { product_id: "123", quantity: 1 }]);
</script>
  • Nothing else. The code records no clicks, scrolling, form fields or anything typed, and a browser cannot send any other activity: no orders, revenue, consent or new contacts. Those come from your server only, because anything a browser sends can be faked.
  • Page views reported elsewhere? If something else already reports page views to YouSendIt, add &pageview=0 to the address in the install code.
  • Limits that protect your plan: one browser records at most 500 events a day and one contact at most 1,000 from all their browsers, and website activity together uses at most half of your monthly event allowance, so your own API calls always have room.

Which visitors are recorded

Activity counts only for visitors we know, so a stranger’s browsing never lands on a contact. A visitor becomes known when they:

  • click a link in one of your emails that leads to one of your connected websites (for 14 days after the email is sent, and in at most 5 browsers a day per contact, because a forwarded email carries the same link),
  • sign up with one of your forms, or
  • are signed in on your site and your site tells the code who they are (below).

Until then, activity is kept anonymously for 30 days. If the visitor becomes known in that time, it is added to the contact’s timeline as past activity; otherwise it is deleted. Each activity on a contact says how its browser was recognized.

Recognize signed-in visitors

An email address on its own never identifies a visitor: otherwise anyone could type someone else’s address and put their browsing on that contact. So your server vouches for the address with a signature, made with the website’s identity secret. The secret never leaves your server; only the signature goes to the page.

Where it livesWho sees it
Identity secret (yis_…)Your server's settings, like an API keyOnly your server
SignatureMade by your server for one email addressThe visitor's browser (it is in the page)

A signature works only for the address it was made for. A signed-in visitor can see their own in the page, but cannot make one for anyone else’s address without the secret.

1. Save the secret on your server. Copy it from Settings → Tracking → Manage → Show install code, and keep it in your server’s environment, for example IDENTITY_SECRET. Never put it in a web page or in your site’s JavaScript.

2. Sign the address on your server. The signature is an HMAC-SHA256 of the lower-cased email address, as hex, with the identity secret as the key. It is the same every time for the same address, so you can make it on each page load or store it with the user.

Node.js
import { createHmac } from "node:crypto";

export function trackingSignature(email) {
  return createHmac("sha256", process.env.IDENTITY_SECRET).update(email.toLowerCase()).digest("hex");
}

3. Put both in the page, and call ysi.identify. When your server renders a page for a signed-in user, it adds their email and signature, after the install code. Two common setups:

Express (server-rendered HTML)
app.get("/account", requireLogin, (req, res) => {
  const email = req.user.email;
  const identity = JSON.stringify({ email, signature: trackingSignature(email) })
    .replace(/</g, "\u003c"); // safe inside a <script>

  res.send(`<!doctype html>
<html>
  <head>
    <script async src="https://yousendit.io/api/client/ysi.js?key=ypk_…"></script>
    <script>
      window.ysi = window.ysi || [];
      ysi.push(["identify", ${identity}]);
    </script>
  </head>
  <body>…</body>
</html>`);
});
Next.js (App Router)
// app/layout.tsx (a Server Component): the secret stays on the server
import { trackingSignature } from "@/lib/tracking";
import { getUser } from "@/lib/auth";
import TrackIdentify from "./TrackIdentify";

export default async function RootLayout({ children }) {
  const user = await getUser();
  return (
    <html>
      <body>
        {user && <TrackIdentify email={user.email} signature={trackingSignature(user.email)} />}
        {children}
      </body>
    </html>
  );
}

// app/TrackIdentify.tsx: only the email and the signature reach the browser
"use client";
import { useEffect } from "react";

export default function TrackIdentify({ email, signature }) {
  useEffect(() => {
    window.ysi = window.ysi || [];
    window.ysi.push(["identify", { email, signature }]);
  }, [email, signature]);
  return null;
}

ysi.push(["identify", …]) works even before the install code has loaded: the call waits for it. Once the script is loaded, ysi.identify(…) does the same.

Good to know

  • Only sign addresses your site has verified (a sign-in by emailed code, a confirmed account). If anyone can register with any address, signing it would link a stranger to that contact.
  • Identifying never creates or changes a contact. If no contact has that address, nothing is linked.
  • Identify on every page a signed-in visitor sees (a shared layout is easiest). Once a browser is linked it stays linked, so repeating it is harmless.
  • If the secret leaks, reset it under Manage → Reset identity secret: old signatures stop working at once, and the install code stays the same, so only your server’s setting changes.