contents of this page
JavaScript Tracker¶
What does the Tracker do?¶
The Parse.ly Tracker (aka Ptrack) is a small piece of JavaScript code that monitors user actions taken on your site to build up rich user profiles for recommendations and expose trending topic information in our analytics product, Parse.ly Dash.
Inserting the tracker on your site¶
You will want to insert the Parse.ly Tracker in the footer of your website template. Ideal placement is as the last code block before the closing of the body tag. If your website uses a templating system, this is usually in the “footer” template.
<!-- START Parse.ly Include: Standard -->
<div id="parsely-root" style="display: none">
<a id="parsely-cfg" data-parsely-site="##########"
href="http://parsely.com">Powered by the Parse.ly Publisher Platform (P3).</a>
</div>
<script>
(function(s, p, d) {
var h=d.location.protocol, i=p+"-"+s,
e=d.getElementById(i), r=d.getElementById(p+"-root"),
u=h==="https:"?"d1z2jf7jlzjs58.cloudfront.net"
:"static."+p+".com";
if (e) return;
e = d.createElement(s); e.id = i; e.async = true;
e.src = h+"//"+u+"/p.js"; r.appendChild(e);
})("script", "parsely", document);
</script>
<!-- END Parse.ly Include -->
Simply copy/paste the code block above. Notice that there is a configuration tag (parsely-cfg) which has a data property, data-parsely-site=”##########”. You must replace the ########## with your own site domain name, e.g. nytimes.com. This ensures that no matter what host name your Parse.ly tag appears on, all the traffic data gets aggregated into a single account.
Completely async loading version¶
If you happen to use LABjs, a third-party library for asynchronous JavaScript loading, you can use this form, which will have better performance than any other option:
<!-- START Parse.ly Include -->
<div id="parsely-root" style="display: none">
<a id="parsely-cfg" data-parsely-site="##########"
href="http://parsely.com">Powered by the Parse.ly Publisher Platform (P3).</a>
<script>
$LAB.script(document.location.protocol==="https:"?
"https://d1z2jf7jlzjs58.cloudfront.net/p.js":
"http://static.parsely.com/p.js");
</script>
</div>
<!-- END Parse.ly Include -->
The LABjs library is only about 3-4kb but can turn many third-party JavaScript integrations into non-blocking, async integrations. We therefore highly recommend it to online sites dealing with third-party JavaScript performance problems. Our scripts at Parse.ly are written to work fine with async loaders like LABjs.
Will this tag break or slow down my site?¶
No way! Our JavaScript code is written in such a way to be the last thing that loads on your page.
We host our DNS servers (parsely.com) with a global, distributed DNS system, which has no downtime and extremely fast resolution times across the globe. Our JavaScript code itself is hosted in a global content delivery network (CDN) with edge locations in every global region.
Our code itself is optimized to not impact user experience in any unintended way. It also automatically leverages asynchronous JavaScript loading technologies in newer browsers. For older browsers, we use a sophisticated loading process that loads a few bytes of data from a high-speed CDN (a “bootstrap” file) and then uses an asynchronous JavaScript loading library (the LABjs library mentioned above) to ensure that none of our other assets block your page load.
Once our tracking code is loaded, we drop an extremely small cookie (just a user ID) and asynchronously beacon back information to our analytics server. If our analytics server is down, all that happens is that the actions are no longer tracked – there is no impact on the user otherwise.
Our team is staffed by JavaScript experts who know the pain and frustration with crappy third-party JavaScript integrations. We therefore have taken a lot of care to make our tracking code integration a no-brainer, safe decision.
Don’t believe us? Check out our public Pingdom report showing our uptime and global response times.
Optimizing tracker placement¶
If you are curious about the optimal placement of tracker code on your website, you can take a look at this article on how tracking scripts affect page loads.