Skip to content

Instantly share code, notes, and snippets.

@buritica
Created December 7, 2012 20:31
Show Gist options
  • Save buritica/4236281 to your computer and use it in GitHub Desktop.
Save buritica/4236281 to your computer and use it in GitHub Desktop.
Onswipe Quantcast Implementation
OnswipePub.prototype.initQuantcastAnalytics = function() {
var ONSWIPE_QUANTCAST_ID = 'p-jFw9eQNm-jBph';
var _qevents = _qevents || [];
// initialize quantcast vars
// if publisher has quantcast id build quantcast object with both theirs and our id
if (_reader.state.publisher.quantcast_id) {
_reader.state.analytics.quantcast_id = _reader.state.publisher.quantcast_id;
// if publisher has quantcast labels build a quantcast object with labels else not
var quantcastLabels = _reader.state.publisher.quantcast_labels && (_reader.state.publisher.quantcast_labels.length > 0);
if (quantcastLabels) {
_reader.state.analytics.quantcast_labels = _reader.state.publisher.quantcast_labels;
_reader.state.analytics.quantcast_obj = [{
qacct:_reader.state.publisher.quantcast_id,
labels:_reader.state.publisher.quantcast_labels
}, {
qacct:ONSWIPE_QUANTCAST_ID
}
];
// else publisher doesn't have category
} else {
_reader.state.analytics.quantcast_obj = [{
qacct:_reader.state.publisher.quantcast_id
}, {
qacct:ONSWIPE_QUANTCAST_ID
}
];
}
// else only onswipe's quantcast id is required
} else {
_reader.state.analytics.quantcast_obj = { qacct:ONSWIPE_QUANTCAST_ID };
}
// apend quantcast analytics script and push initial pageview
var s = document.createElement("script");
s.type = "text/javascript";
s.src = (document.location.protocol === "https:" ? "https://secure" : "http://edge") + ".quantserve.com/quant.js";
// s.async = true;
s.onload = function(){
_qevents.push(_reader.state.analytics.quantcast_obj);
};
var scpt = document.getElementsByTagName("script")[0];
scpt.parentNode.insertBefore(s, scpt);
};
@anabelle
Copy link

anabelle commented Dec 7, 2012

yo pensé que iba a compartir una receta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment