I want to make my code fake the refferer header in analytic systems(such as google analytics) , but It doesn't work. I have add 'var settings ={...//...}' and add 'page.onLoadStarted = function() {page.customHeaders = {};' and add - 'page.open(...,settings, ...' , but it still recognised like direct traffic in the analytics. Here is the code:
var page = require('webpage').create();
var settings = {
headers: {
"Referer": "http://google.com"
}
};
var urls = ['http://china.com/','http://usa.com/','http://emirates.com/'];
var i = 0;
function OpenPage(){
setTimeout(function(){
page.onLoadStarted = function() {
page.customHeaders = {};
};
page.open(urls[i],settings, function(status) {
if (status == 'success') {
page.render('example' + i + '.png');
}
i++;
if(i <= urls.length - 1){
OpenPage();
}else{
phantom.exit();
}
});
},5000);
}
OpenPage();
I get this code from this question https://stackoverflow.com/a/42468998/4999509 and it worked like a charm, respect for coder - Flash Thunder !