V
V
Vladimir2014-09-08 12:17:39
Google Analytics
Vladimir, 2014-09-08 12:17:39

How to track whether a new zone for a domain has been propagated through Google Analytics?

I can get the new_hosting variable in Javascript on the site, which will be equal to 0 if the site is viewed on the old hosting and 1 if on the new one, but here's how to use this variable in Google Analytics to quickly get a report on the number of visits on the old hosting and on the new hosting per day , I do not know.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2014-09-09
@Casufi

https://developers.google.com/analytics/devguides/...
In order not to put the site down, I set up nginx on the new hosting, which takes the content on the old one by IP and gives it to users who have the new zone working + nginx adds a label indicating that the site is served through a proxy.

proxy_pass http://IP/$1$is_args$args;
                proxy_set_header Host $host;
                proxy_redirect off;
                proxy_read_timeout 600s;
                proxy_send_timeout 600s;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-My-Domain $host;

After that, in the Btrix template (Bitrix has a mixture of PHP and HTML in the templates)
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '***KEY***', 'auto');
ga('require', 'linkid', 'linkid.js');
<?if(array_key_exists("HTTP_X_MY_DOMAIN",$_SERVER)):?>
var ProxyDomain = '<?echo($_SERVER["HTTP_X_MY_DOMAIN"])?>';
<?else:?>
var ProxyDomain = 'No proxy';
<?endif;?>
ga('set', 'dimension1', ProxyDomain);
ga('send', 'pageview');
</script>

Well, follow the link at the beginning of the answer

P
Puma Thailand, 2014-09-08
@opium

it's better to look at the webserver logs on the old and new.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question