etracker
Analytics Editions / Pricing Live-Demo
etracker
Optimiser Editions / Pricing Live-Demo
Pricing For Agencies Support

Set up cookie upgrade on the server side

Background

Current versions of the Safari browser and future versions of Firefox implement a new privacy policy that limits certain browser cookies to a maximum duration of 7 days. These are client-side cookies. Such cookies, which – unlike server-side cookies – are set by the JavaScript code on the website.

The cookies that etracker uses for visitor recognition are also set on the client side and are thus “forgotten” in new Firefox installations if a visitor does not return within 7 days.

The Cookie Upgrade Solution

Remedy for the cookie problem described is provided by our cookie upgrade solution. This consists of a small PHP script (less than 1 KB) that is hosted by the site operator itself on its website. The script is loaded from the browser below the website domain and can set cookies on the server side that do not expire after 7 days. The following technical guide describes how to set up the server-side cookie upgrade.

Conditions

Your server environment must have at least PHP 4 installed.

The Cookie Upgrade Script

You can download the cookie upgrade script here: https://code.etracker.com/cookie-upgrade.php.

Upload Cookie Upgrade Script

The cookie upgrade script must be uploaded to the web server and must be available under your own domain.

Example:
Your domain measured with etracker is https://kundenseite.de. Then the cookie upgrade script could be available at https://kundenseite.de/etracker/cookie-upgrade.php.

You can also use a subdomain where you expose the script:e.g. on https://tracking.kundenseite.de/cookie-upgrade.php

Customize etracker code

The <script> element into which the e.js is loaded must be extended by the additional attribute data-cookie-upgrade-url. The data-cookie-upgrade-url attribute specifies which URL the cookie upgrade script can use to run the cookie upgrade script.

For the previous example (script is under: https://kundenseite.de/etracker/cookie-upgrade.php), calling the etracker code in the source code of your website may look like this:

 

<script id="_etLoader"
        data-respect-dnt="true"
        data-secure-code="XXXXXX"
        data-cookie-lifetime="24"
        data-cookie-upgrade-url="https://kundenseite.de/etracker/cookie-upgrade.php"
        src="https://static.etracker.com/code/e.js">
</script>

Please note that you will need to use the account key of your etracker account for “XXXXXX”.

Setup without PHP

If you want to use the cookie upgrade without using PHP, you must set up an endpoint that behaves in the same way as the cookie upgrade script.
The endpoint is called via GET and expects the following URL parameters:

  • cookie_name
  • expires
  • domain (optional)

The response is ignored. For implementation details, please use the PHP script as a template.

 

Need help?
Our friendly, knowledgeable support engineers are here for you.