Tech docs
Integration Docs
Alternative Integrations

Alternative Integrations

Below are alternative methods for adding Parse.ly tracking to your site, if the default is not possible. Always replace ###### in the examples with your site id, e.g. mysite.com, as its registered with Parse.ly.

#Load the tracker via JavaScript

Use this method when you can't add custom HTML to your templates, or if your tag management system only allows JavaScript.

The following code dynamically creates an HTML <script> element, then loads the Parse.ly tracker in the standard way:

(function(d) {
    var b = d.body;
    var e = d.createElement('script');

    e.id = 'parsely-cfg';
    e.src = '//cdn.parsely.com/keys/######/p.js';
    b.appendChild(e);
})(document);

#Load the tracker in an iframe element

Use this method if you are unable to insert the Parse.ly tracker directly into the HTML markup of your pages, and must instead insert it into an iFrame:

First, on your server create a file called parsely.html with the following markup:

<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<!-- START Parse.ly Include: Standard -->
<script id="parsely-cfg" src="//cdn.parsely.com/keys/######/p.js"></script>
<!-- END Parse.ly Include: Standard -->
</body>
</html>

Then, add an iframe element to all the trackable pages, with the src pointing to that HTML file.

<iframe name="parsely_tag" src="/path/to/parsely.html" style="display: none" width="0" height="0" tabindex="-1"></iframe>

The parsely.html file should be accessible on the same protocol (http/https), domain, and port as the page which contains the iframe itself or the JavaScript will fail to execute due to cross-site scripting limitations.

#Configure the tracker to always use browser localStorage instead of cookies

By default, the Parse.ly tracker uses cookies to keep track of visitors and sessions. However, this data can be stored in each browser's window.localStorage instead.

To use localStorage instead of cookies, simply make sure PARSELY.use_localstorage = true prior to loading the tracker, as in this example:

<script>
    window.PARSELY = window.PARSELY || {
        // ... other Parsely configuration options
        use_localstorage: true
        // ... other Parsely configuration options
    };
</script>

<!-- START Parse.ly Include -->
<!-- ...insert the parse.ly tracker code here... -->
<!-- END Parse.ly Include -->

One major limitation of localStorage is that, unlike cookies, data does not persist across subdomains. This means that if your site spans multiple subdomains (such as blog.parsely.com and help.parsely.com), cookies can use the same visitor and session data as a user navigates between them, but localStorage cannot. That difference would result in higher visitor counts and more new visitors in the Parse.ly dashboard and API when using localStorage.

The Parse.ly tracker automatically uses localStorage in browsers such as Safari where cookie expiration would otherwise prevent accurate data collection. No additional configuration is required for this behavior.

rocket emoji