Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

inherited the view website.layout to replace tags script

By
tansadio
on 12/3/14, 8:16 AM 1,139 views

 I added this code but it does'nt.  Can someone help me.

<template id="layout_google_analytic" inherit_id="website.layout" name="Script google analytic">
            <xpath expr="//html//body//script[@t-if='website and website.google_analytics_key']" position="replace">
                <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','<t t-esc="website.google_analytics_key"/>', 'auto');
                ga('send','pageview');
                </script>
            </xpath>
        </template>

I inform you that the position is replace instead of After

tansadio
on 12/3/14, 8:28 AM
0
tansadio
On 12/5/14, 10:32 AM

This code works

<template id="layout_google_analytic" inherit_id="website.layout" name="Script google analytic">
            <xpath expr='//script["website and website.google_analytics_key"]' position="replace">
                <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','<t t-esc="website.google_analytics_key"/>', 'auto');
                ga('send','pageview');
                </script>
            </xpath>
        </template>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/3/14, 8:16 AM
Seen: 1139 times
Last updated: 3/16/15, 8:10 AM