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 to. 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:

<script>
!function(c,n,a,i){c.PersosaObject=i,c[i]=c[i]||function(e,s,t,r,o){"init"===e&&s?(t=t||{},(o=n.createElement(a)).async=!1!==t.jsAsync,o.src="//edn.persosa.com/web.js?id="+s+"&o="+btoa(JSON.stringify({p:c.location.href,r:n.referrer,cux:!1!==t.consistentUX,co:!!t.campaignOverride,ar:!1!==t.autoRender})),(r=n.querySelector("head")).insertBefore(o,r.querySelector(a)),!1!==t.loadCSS&&((o=n.createElement("link")).type="text/css",o.rel="stylesheet",o.href="//cdn.persosa.com/t/"+s+"/c/_live/"+c.location.hostname+".css",o.async=0,r.appendChild(o),setTimeout(function(){n.body.classList.add("persosa-r")},3e3))):(c[i].q=c[i].q||[]).push(arguments)}}(window,document,"script","persosa");

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

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?