Skip to content

Instantly share code, notes, and snippets.

@phillipadsmith
Last active July 14, 2016 22:31
Show Gist options
  • Save phillipadsmith/65611468ec78b50a0e480f641cc1c22f to your computer and use it in GitHub Desktop.
Save phillipadsmith/65611468ec78b50a0e480f641cc1c22f to your computer and use it in GitHub Desktop.
Chartbeat weirdness
<script type='text/javascript'>
var _sf_async_config = _sf_async_config || {};
/** CONFIGURATION START **/
_sf_async_config.uid = #####; //CHANGE THIS
_sf_async_config.domain = 'YourDomain.com'; //CHANGE THIS
_sf_async_config.useCanonical = true;
_sf_async_config.sections = 'Change this to your Section name'; //CHANGE THIS
_sf_async_config.authors = 'Change this to your Author name'; //CHANGE THIS
/** CONFIGURATION END **/
(function() {
function loadChartbeat() {
window._sf_endpt = (new Date()).getTime();
var e = document.createElement('script');
e.setAttribute('language', 'javascript');
e.setAttribute('type', 'text/javascript');
e.setAttribute('src', '//static.chartbeat.com/js/chartbeat.js');
document.body.appendChild(e);
}
var oldonload = window.onload;
window.onload = (typeof window.onload != 'function') ?
loadChartbeat : function() {
oldonload();
loadChartbeat();
};
})();
</script>
@phillipadsmith
Copy link
Author

phillipadsmith commented Jul 14, 2016

What are the scenarios where line 18 line 20 above might NOT fire the loadChartbeat function?

This is copied from here: http://support.chartbeat.com/docs/#code

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