Skip to content

Help Center

Remove Console Log

When you have Attributer installed on your website, it adds a few entries to the Console log. This is useful for our customer service teams in supporting our customers as it helps us see whether Attributer is running on a particular page.

If for whatever reason you wish to hide this, you can do so by adding the below script ABOVE the original Attributer script.

<script>
(function(functionsToPreserve = ["error"]) {
function noop() {}

//ensure we KNOW that there is a log function here, just in case
const savedFunctions = { log: console.log }
//proceed with nuking the rest of the chattiness away
Object.keys(console)
.reduce((memo, key) => {
if(typeof console[key] == "function" && functionsToPreserve.indexOf(key) != -1 ) {
memo[key] = console[key];
console[key] = noop;
}
return memo;
},
savedFunctions); //<- it's a const so we can't re-assign it. Besides, we don't need to, if we use it as a seed for reduce()
console.log = function customLog() {
//index 0 - the error message
//index 1 - this function
//index 2 - the calling function, i.e., the actual one that did console.log()
const callingFile = new Error().stack.split("\n")[2];
if (![...arguments].some(entry => (typeof entry === 'string' || myVar instanceof String) && entry.match(/attributer/ig))) {
savedFunctions.log.apply(console, arguments)
}
}

})()
</script>

Can't find the answer you need? Contact us!

Our team are available to answer any questions you have

Support Images