Set additional label based on event for Quantcast

Quantcast is a great resource and data source for site owners and clients.  One of the first to provide demographics data in the web analytics space.  Thier feature for “labels” or “Audience Segments” as its also known is an even more powerful way to extend and get more out of this demographic data as it relates to your site visitors.

Labels are easy to set up, and this is the familiar signature to set them in the Quantcast tag:

_qevents.push({
qacct:"p-12345abce",
labels:"labelgoeshere"
});

Of course as time goes on we like to start pushing the boundaries.  It’s fun to segment and add additional context to visitors – but the one limitation to Quantcast is that it seems to be very pageview-based.  So if you want to set  a label it needs to be known at the time you first load the tag, and nothing more about behavior on that page can be used to inform a label/segment at this point.  In my case, all we wanted to do was set a label based on a click of a button.

function clickHandler(){
  _qevents.push({
    //handler wrapper to fire on event within page
    qacct:__qc.qpixelsent.pop(), //set qacct ID to last ID
    labels:"Action.Click"  //set labels as desired
  });
}

For the internals of the Quantcast script, they keep an array of account IDs you’ve already sent a pixel for in that pageview.  What I’m doing above is simply using .pop() to remove the last ID Quantcast was fired for, and re-firing the tag with my new labels.  This was the main hurdle of the whole thing, and I thought this was slick since we’re not re-defining the Quantcast ID used in the tag (assuming this click handler code is initiated by other scripts on the page).  Obviously I’m overriding a few features within Quantcast, but all I can see would be two issues:

  • Overwriting one audience segment for a visitor with another.
    • As far as I can tell, the labels are fairly additive instead of singular/exclusive.
    • I can set an arbitrary label each page – so the effect here should be the same.
  • Inflation of Quantcast traffic numbers
    • I see this as the real danger, based on the way they force you into a pageview model – each pixel call is probably being recorded as a pageview.
    • Our in-page second call to Quantcast will inflate the pageview traffic numbers reported by Quantcast
    • With panel type data – you shouldn’t be worried about segmentation by pageviews anyway…

Leave a Reply

Your email address will not be published.