โดย pond » 13/09/2016 6:53 pm
ขั้นแรกเลยให้ไปที่ไฟล์ #XML ของ #Template ก็คือไฟล์ templateDetails.xml เข้าไปเพิ่ม code แท็ก fieldset
โค้ด: เลือกทั้งหมด
<field name="googleanalyticsnaja" class="" type="text" default=""
label="Google Analytics"
description="Google Analytics" />
จากนั้นให้ไปที่ไฟล์ index.php นำ code javascript นี้ไปไว้ใน head
โค้ด: เลือกทั้งหมด
<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', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', '<?php echo $this->params->get('googleanalyticsnaja')?>', 'auto');
ga('send', 'pageview');
</script>
หลังจากนั้นให้ทำการ Login กดไปที่ template ที่ทำการแก้ไขเลือกที่ Advanced ให้กรอก Code ที่ได้จาก
Google Analytics เสร็จแล้วกด save
- ana.png (24.52 KiB) Viewed 763 times
เมื่อไปดูในส่วนของไซต์ กดคลิกขวา View Source ดูจะเห็นว่า เราสามารถใช้ได้แล้ว
- anafi.png (57.21 KiB) Viewed 763 times
ขั้นแรกเลยให้ไปที่ไฟล์ #XML ของ #Template ก็คือไฟล์ templateDetails.xml เข้าไปเพิ่ม code แท็ก fieldset
[code] <field name="googleanalyticsnaja" class="" type="text" default=""
label="Google Analytics"
description="Google Analytics" />[/code]
จากนั้นให้ไปที่ไฟล์ index.php นำ code javascript นี้ไปไว้ใน head
[code] <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', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', '<?php echo $this->params->get('googleanalyticsnaja')?>', 'auto');
ga('send', 'pageview');
</script>[/code]
หลังจากนั้นให้ทำการ Login กดไปที่ template ที่ทำการแก้ไขเลือกที่ Advanced ให้กรอก Code ที่ได้จาก [b][u][url=https://www.mindphp.com/%E0%B8%84%E0%B8%B9%E0%B9%88%E0%B8%A1%E0%B8%B7%E0%B8%AD/73-%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3/3507-google-analytics.html?bb_limitstart=12060]Google Analytics[/url][/u][/b] เสร็จแล้วกด save
[attachment=1]ana.png[/attachment]
เมื่อไปดูในส่วนของไซต์ กดคลิกขวา View Source ดูจะเห็นว่า เราสามารถใช้ได้แล้ว
[attachment=0]anafi.png[/attachment]