Template Joomla ฟิก GoogleAnalytic

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: Template Joomla ฟิก GoogleAnalytic

Template Joomla ฟิก GoogleAnalytic

โดย 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
ana.png (24.52 KiB) Viewed 763 times
เมื่อไปดูในส่วนของไซต์ กดคลิกขวา View Source ดูจะเห็นว่า เราสามารถใช้ได้แล้ว
anafi.png
anafi.png (57.21 KiB) Viewed 763 times

ข้างบน