Tech docs
Integration Docs
Conversion Tracking

Conversion Tracking

Take care when configuring conversion events - once they're sent, they'll appear in the Parse.ly reporting suite, and we cannot remove that data. We recommend implementing on a testing site first.

#Conversion actions

Parse.ly currently supports five categories of conversion events, plus custom events: Each conversion action is a combination of two identifying attributes:

  • Type - The category of the conversion (described in the function). Parse.ly supports six types, which you can choose from.
  • Label - The name of the specific action taken by a user (described in the parameter). You have the freedom to specify the label.

#Conversion types

Parse.ly currently supports five standard conversion types and one custom type:

  1. Lead Capture - When a user provides identifying details (e.g. email, name) via a form to indicate they have interest in what the company is selling (i.e. a lead). See example code.
  2. Link Click - When a user clicks a link or button (e.g. an internal link or affiliate link). See example code.
  3. Newsletter Signup - When a user provides their email via a form in order to receive emails from a company, such as a newsletter or an email course. See example code.
  4. Subscription - When a user buys a subscription that will result in recurring revenue. See example code.
  5. Purchase - When a user completes the one-time purchase of a product. See example code.
  6. Custom - When a user completes an action not covered by the five standard events. See example code.

In the future, Parse.ly may provide benchmark comparisons of the standard categories of events (e.g. comparing how your newsletter signup performance compares to rest of the Parse.ly network). For this reason, we discourage using custom types except when absolutely necessary.

#Sending a conversion event with a label

When a conversion event is triggered, call PARSELY.conversions.<relevant function name> to send the data to Parse.ly's servers. Each function takes one parameter, which is a descriptive label for the conversion event. Labels may appear in the reporting suite, so spaces and capitalization are supported.

PARSELY.conversions.trackLeadCapture('Demo Request');
keyTypeRequiredDescription
labelstringyesA string specific to a particular implementation

Note that the PARSELY.conversions.<track functions> functions are available only after the tracker code has finished loading. To capture conversion events that may occur before the tracker loads, continue to the next section.

#Handling conversions whenever they occur

Because it's possible for a conversion event to happen before the tracker has fully loaded, it's recommended to use a wrapper function (captureParselyLeadConversion in the example below), rather than calling a method which may not yet exist. Using the example of a lead capture from above, you might have something like this on a lead-gen page:

// make a queue for conversion events
var parselyConversionEventQueue = [];

// wrapper function safely handles either case
function captureParselyLeadConversion(label) {
    if (window.PARSELY && window.PARSELY.loaded) {
        window.PARSELY.conversions.trackLeadCapture(label);
    } else {
        parselyConversionEventQueue.push(label);
    }
}

// run this safely whenever you capture an event
captureParselyLeadConversion('Demo Request');

// flush the queue when the tracker loads
window.PARSELY = window.PARSELY || {
    onload: function() {
        for (var i = 0; i < parselyConversionEventQueue.length; i++) {
            PARSELY.beacon.trackLeadCapture(parselyEventQueue[i]);
        }
    }
};

// insert the parsely tracker code here...

#Important

Any code that sets PARSELY.onload (such as the example above) must be executed before the loading Parse.ly tracker.

#Sample Implementations

The following examples are necessarily simplified for illustration purposes, and are not meant to be used as-is.

#Lead Capture conversion example

Use trackLeadCapture when a user provides identifying details (e.g. email, name) via a form to indicate they have interest in what the company is selling.

Some examples include:

  • Signing up for a demo
  • Creating an account to start a 30-day trial
  • Signing up for a rewards program

In this example, generated leads are also distinguished by their "active" status.

// listen for submit events on a form, to indicate a lead capture
var form = document.getElementById('demo-request-form');
form.addEventListener('submit', PARSELY.conversions.trackLeadCapture('Demo Request'), false);

// Alternately, you might want to distinguish leads who were already active users...
function trackParselyLead(e) {
    // determine if the user is active based on the session count
    var userSessionCount = PARSELY.lastRequest.sid;
    var userStatus = userSessionCount > 5 ? "active" : "new";
    PARSELY.conversions.trackLeadCapture(userStatus);
}
form.addEventListener('submit', trackParselyLead, false);

#Newsletter signup conversion example

Use trackNewsletterSignup when a user submits their email address via a form to subscribe to a newsletter or other email program.

// listen for click events on a button which indicates a newsletter signup
var btn = document.getElementById('newsletter-signup-button');
btn.addEventListener('click', PARSELY.conversions.trackNewsletterSignup('Politics Newsletter Sign Up'), false);

#Subscription conversion example

Use trackSubscription when a user buys a subscription product that will result in recurring revenue. (For one-time purchases, use trackPurchase.)

Some examples include:

  • a software subscription
  • a monthly/weekly subscription box
  • a content subscription (e.g. for a streaming service, a newspaper)
  • a recurring donation

Here, a monthly subscription to a beauty box is tracked.

var form = document.getElementById('glam-box-subscribe');
form.addEventListener('submit', PARSELY.conversions.trackSubscription('Glam Box Monthly Subscription'), false);

#Purchase conversion example

Use trackPurchase when a user makes a one-time purchase of a product. (For purchases that result in recurring revenue, use trackSubscription.)

Some examples include:

  • buying a ticket to an event
  • buying a pair of shoes
  • making a one-time donation

Instead of a monthly subscription, this example tracks a one-time purchase of a pair of shoes.

var form = document.getElementById('men-sneaker-id-5436-purchase');
form.addEventListener('submit', PARSELY.conversions.trackPurchase("Men's Sneaker Id 5436"), false);

Use trackLinkClick when a user clicks a link (in-line, button, banner, etc).

Some examples include:

  • when a user clicks a call-to-action (such as a Subscribe button or a product recommendation). This can indicate intent, even if the user doesn’t complete the intended action (e.g. clicking a Subscribe button, but not completing payment for the subscription).
  • when a user clicks an affiliate link
  • when a user clicks from a blog post to landing page
  • when a user clicks a social share button

In this example, sometimes we want to send a generic label when the link matches some domain; otherwise, we might want to track the entire link itself.

var ecomDomain = "some.specific.domain.com";
function parselyLinkClickConversionCallback(e) {
    if (
        e.target.tagName === 'A'
        && e.target.href.indexOf(ecomDomain) !== -1
    ) {
        // Can inspect the events to send custom labels
        // for specific events...
        PARSELY.conversions.trackLinkClick('E-commerce Link Click');
    } else {
        // ... or simply send the link that was clicked.
        PARSELY.conversions.trackLinkClick(e.target.href);
    }
}
document.addEventListener('click', parselyLinkClickConversionCallback, false);

#Custom conversion example

Use trackCustom when a user completes an event that is not covered by the five standard categories above.

Some examples include:

  • when a user lands on an important page
  • when a user comments on content

#Note about Custom Events and Benchmarking

Because Custom events are not standardized, Parse.ly will not be able to benchmark these events and give you insight on how your performance compares to Parse.ly’s network as a whole. For this reason, we discourage the use of custom events unless absolutely necessary.

Here are some examples that might not fit into the above categories:

// capture interactions with an online voting widget, for example...
var ballot = document.getElementById('vote-box');
function trackUserVote(e) {
    // use event metadata to determine which option they voted for
    var vote = "voting-choice";
    PARSELY.conversions.trackCustom(vote);
}
ballot.addEventListener('click', trackUserVote, true);

// Perhaps you would like to see which content influences
// users to get farthest into a survey or form...
var formFields = document.getElementsByTagName('input');
function userAttemptsField(e) {
    // only send events when users try to fill in certain fields
    if (e.target.className.indexOf("goal-input-field") < 0) {
        return false;
    }
    var fieldname = e.target.name;
    PARSELY.conversions.trackCustom('form-123-focus-' + fieldname);
}
for (i = 0; i < formFields.length; i++) {
    formFields[i].addEventListener('focus', userAttemptsField);
}
rocket emoji