MediaWiki:Common.js: Difference between revisions

Cache the add-on scripts for 5 minutes instead of 5 hours
GA: skip missing pages; add site_check parameter to filter fake hits
 
Line 142: Line 142:
var ns = mw.config.get( 'wgNamespaceNumber' );
var ns = mw.config.get( 'wgNamespaceNumber' );
if ( [ 0, 4, 14, 3000 ].indexOf( ns ) === -1 ) {
if ( [ 0, 4, 14, 3000 ].indexOf( ns ) === -1 ) {
return;
}
/* Pages that do not exist (404) are not counted; category pages without text are still counted */
if ( mw.config.get( 'wgArticleId' ) === 0 && ns !== 14 ) {
return;
return;
}
}
Line 165: Line 169:
window.gtag = function () { window.dataLayer.push( arguments ); };
window.gtag = function () { window.dataLayer.push( arguments ); };
window.gtag( 'js', new Date() );
window.gtag( 'js', new Date() );
window.gtag( 'config', id );
/* site_check marks hits sent by this code; reports can be filtered on it to drop fake hits sent straight to Google */
window.gtag( 'set', { site_check: 'cp1' } );
window.gtag( 'config', id, { site_check: 'cp1' } );
}
}
events.forEach( function ( ev ) {
events.forEach( function ( ev ) {