PDA

View Full Version : Universal Analytics in vBulletin


SWSUSA
08-11-2015, 02:21 PM
Hi! How to insert the code Universal Analytics?

Привет! Как вставить код Universal Analytics?

<script>
(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', 'UA-32257551-1', 'auto');
ga('send', 'pageview');

</script>


Реализация PHP

Создайте файл analyticstracking.php с приведенным выше кодом и добавьте его с помощью директивы include во все шаблоны страниц PHP. Затем добавьте следующую строку на каждый шаблон страницы непосредственно после открывающего тега <body>:
<?php include_once("analyticstracking.php") ?>

RichieBoy67
08-11-2015, 03:06 PM
Add it to your headincludes at the bottom.

SWSUSA
08-11-2015, 03:15 PM
Add it to your headincludes at the bottom.

How to add analyticstracking.php file using the include directive to all page templates PHP?

Как добавить файл analyticstracking.php с помощью директивы include во все шаблоны страниц PHP?

squidsk
08-11-2015, 05:35 PM
The code you supplied in the OP is javascript and not php, so does not need to be in a php file.

SWSUSA
08-12-2015, 04:28 AM
The code you supplied in the OP is javascript and not php, so does not need to be in a php file.

Do not understand. Google writes the code in the PHP file.

Не понял. Google пишет добавить код в PHP файл.

RichieBoy67
08-12-2015, 04:35 AM
All you have to do is paste the code into your headincludes. You do not need the php file. The headinclude will include it in all your templates.

SWSUSA
08-12-2015, 04:44 AM
All you have to do is paste the code into your headincludes. You do not need the php file. The headinclude will include it in all your templates.

I am afraid that with this method the speed of loading pages will be more.

Я боюсь, что с помощью такого метода скорость загрузки страниц будет больше.

RichieBoy67
08-12-2015, 05:02 AM
I am afraid that with this method the speed of loading pages will be more.

Я боюсь, что с помощью такого метода скорость загрузки страниц будет больше.

Actually if you are that worried about it the code will also work in the footer but most suggest the headincludes. I do not see how adding the code directly to the file is going to be slower than having it called.