N
N
night_amir2011-11-24 15:07:13
JavaScript
night_amir, 2011-11-24 15:07:13

Google Analytics and redirect to JS

Friends, I'm trying to catch the number of clicks using Google. Everything works, but when using this redirect: Google does not count the transition to this page. Inexplicably. Now the scheme is as follows: We go to the page - the GA considers the visit - a redirect. Without a redirect, the visit counts. Tell me, has anyone experienced something similar? It won't work on the PHP header, since you can't send anything to the output before it, including the GA counter.

script type="text/javascript"
var url = "<?php echo $urls[$use]; ?>";
window.location.href = url;
/script

noscript
У вас отключен JavaScript. Для перехода нажмите сюда.
/noscript





Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
homm, 2011-11-24
@homm

Because analytics scripts are loaded asynchronously, after your redirect is completed.

S
sdevalex, 2011-11-25
@sdevalex

so try...
window.onload = function(){ window.location.href = url; }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question