Skip to main content

First-party and server-side cookies with Triggerbee

You can have Triggerbee's cookies set by your own server, on your own domain, instead of by the browser. To do this, you route Triggerbee's tracking through a path on your website (a reverse proxy). Returning visitors are then recognized for longer.

Beta: Server-side cookies are in beta. Contact [email protected] if you have questions or run into problems.

Why server-side cookies?

Browsers like Safari and Firefox shorten the lifetime of cookies set by JavaScript in the browser. A returning visitor can then look like a new visitor after only a few days.

Cookies set by your own server on your own domain last longer. This gives you:

  • More returning visitors recognized as returning.

  • More accurate data and personalization over time.

The cookies are set on your account's primary website domain.

Before you start

  • A proxy path on your website. You need a path on your site, /tb by default, that forwards requests to Triggerbee. Depending on your platform, you'll probably need help from a developer.

  • Admin rights on your Triggerbee account to turn on the setting in Step 3.

Important: Do the steps in order, and only turn on the setting in Step 3 once Steps 1 and 2 are tested. If you turn it on too early, visitor history is lost.


Step 1: Set up your proxy

Set up your website so that everything under https://yourdomain.com/tb/ is forwarded to https://t.myvisitors.se.

We have ready-made setup guides for:

Platform

Guide

Cloudflare (Workers)

PHP sites (for example, WordPress or a custom PHP site)

Using another platform?

You can set up the proxy on most platforms, for example:

  • Vercel, Netlify or Next.js: rewrites or edge functions.

  • Nginx, Apache or IIS: a rule for /tb that forwards to https://t.myvisitors.se.

  • AWS, Fastly or another CDN: Lambda@Edge or Fastly VCL.

Whatever you use, the proxy must:

  • Send the visitor's IP address to Triggerbee in the X-Client-IP header.

  • Send the visited host and protocol in the X-Forwarded-Host and X-Forwarded-Proto headers.

  • Return Triggerbee's Set-Cookie headers to the browser unchanged.

Test the proxy

Open https://yourdomain.com/tb/js?site_id=YOUR_SITE_ID in your browser. If you see JavaScript code, the proxy works.


Step 2: Update your tracking code

In your Triggerbee tracking code, change the script address from https://t.myvisitors.se to https://yourdomain.com/tb.

  • Keep www if your site uses it.

  • To check it, open your site, then open the Network tab in your browser's developer tools and confirm that the Triggerbee script loads from your own domain.

Google Tag Manager: The Triggerbee GTM template can't be used with server-side cookies. Add the tracking code in a Custom HTML tag or directly in your site's source code instead. The Triggerbee event templates still work.

Step 3: Turn on server-side cookies in Triggerbee

Only do this after Steps 1 and 2 are tested.

  1. Go to My Triggerbee > Account settings.

  2. Open Web Tracking.

  3. Turn on Use server-side cookies.

  4. Click Save and confirm.
    ​

Backwards compatibility

  • Switching from client-side to server-side cookies is safe. Existing visitors are carried over the next time they load a page.

  • Switching back is not possible without losing data. Treat this as a one-way change, and only turn it on when you're committed to keeping it.
    ​

Limitations

Server-side cookies only work on your account's primary website domain and its subdomains. New visitors on additional domains may not be tracked.

Did this answer your question?