The Persosa tracking code is what tracks visitors on your website across multiple sessions. It keeps track of pageviews, events, properties, and anything else you tell it. In order to show targeted content on your website, the tracking code must exist on every page.

Find tracking code

To access your specific tracking code, log in to your account and click the Tracking Code link from the dropdown menu in the top right. Your tracking code will look something like this:

<style>body:not(.persosa-r) .persosa-block:not(.persosa-r) { visibility:hidden !important; }</style>
!function(t,c,i){function a(e){var s=c.cookie.match("(^|[^;]+)\\s*"+e+"\\s*=\\s*([^;]+)");return s?s.pop():""}t.PersosaObject=i,t[i]=t[i]||function(e,s,n,o,r){"init"===e&&s?(n=n||{},(r=c.createElement("script")).async=!1!==n.jsAsync,r.src="//"+s+"&o="+btoa(JSON.stringify({p:t.location.href,r:c.referrer,cux:!1!==n.consistentUX,co:!!n.campaignOverride,ar:!1!==n.autoRender}))+"&clid="+encodeURIComponent(a("persosa_clid"))+"&s="+encodeURIComponent(a("persosa_ssid_"+s)),(o=c.querySelector("head")).insertBefore(r,c.currentScript.nextSibling),!1!==n.loadCSS&&((r=c.createElement("link")).type="text/css",r.rel="stylesheet",r.href="//"+(new RegExp("[\\?&]persosa_preview=([^&#]*)","i").exec("_":"")+""+s+"/c/_live/"+t.location.hostname+".css",r.async=0,o.insertBefore(r,c.currentScript.nextSibling)),setTimeout(function(){c.body.classList.add("persosa-r")},3e3)):(t[i].q=t[i].q||[]).push(arguments)}}(window,document,"persosa");

persosa('init', '<ACCOUNT_ID>');

Where to place the code

Insert this code into the <head>  portion of the HTML on every page on your website. By default, the Persosa tracking code loads a CSS file synchronously (which will hide potential Persosa regions on the page) and loads the tracking code asynchronously.

By default, the CSS is loaded synchronously so that potentially modified regions are hidden before changed (to avoid a flash). While there may be a slight page load penalty, it is less than it would be for loading JavaScript and typically returns to the browser in less than 30 milliseconds.

By default, the JavaScript tracking code is loaded asynchronously at the end of the header. When the tracking code loads, it executes any commands previously passed to it and renders the appropriate experience on the page, showing regions as soon as they're modified.

Do I need to track pageviews?

Nope! Contrary to how other trackers work (e.g., Google Analytics), a pageview request will automatically be made when the page is loaded.

Did this answer your question?