Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] New module 'website_google_tag_manager' #278

Merged
merged 4 commits into from
Dec 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions website_google_tag_manager/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

==================
Google Tag Manager
==================

This module allows to configure your Odoo website to support
the Google `Tag Manager <https://www.google.com/analytics/tag-manager/>`_ tool.

Configuration
=============

To configure this module, you need to:

* go to `Website Admin/Configuration`
* fill in your `Google Tag Manager Key` (e.g. `GTM-ABCDEF`)

.. figure:: website_google_tag_manager/static/description/image.png
:alt: alternative description
:width: 600 px

Usage
=====

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/186/9.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/website/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Sebastien Alix <[email protected]>

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.
3 changes: 3 additions & 0 deletions website_google_tag_manager/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import models
22 changes: 22 additions & 0 deletions website_google_tag_manager/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Copyright 2016 ABF OSIELL <http://osiell.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Google Tag Manager",
"version": "9.0.1.0.0",
"author": "ABF OSIELL, Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Website",
"summary": "Add support for Google Tag Manager",
"depends": [
'website',
],
"data": [
"views/website_config_settings.xml",
"views/website.xml",
'views/templates.xml',
],
"auto_install": False,
'installable': True,
"application": False,
}
4 changes: 4 additions & 0 deletions website_google_tag_manager/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-

from . import website
from . import website_config_settings
11 changes: 11 additions & 0 deletions website_google_tag_manager/models/website.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright 2016 ABF OSIELL <http://osiell.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import models, fields


class Website(models.Model):
_inherit = 'website'

google_tag_manager_key = fields.Char(u"Google Tag Manager Key")
12 changes: 12 additions & 0 deletions website_google_tag_manager/models/website_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
# Copyright 2016 ABF OSIELL <http://osiell.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import models, fields


class WebsiteConfigSettings(models.TransientModel):
_inherit = 'website.config.settings'

google_tag_manager_key = fields.Char(
related=['website_id', 'google_tag_manager_key'])
79 changes: 79 additions & 0 deletions website_google_tag_manager/static/description/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions website_google_tag_manager/views/templates.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2016 ABF OSIELL <http://osiell.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>

<template id="layout" inherit_id="website.layout">
<xpath expr="html/body/*[1]" position="before">
<t t-if="website and website.google_tag_manager_key">
<!-- Google Tag Manager (noscript) -->
<noscript><iframe t-attf-src="https://www.googletagmanager.com/ns.html?id=#{website.google_tag_manager_key}" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
</t>
</xpath>
<xpath expr="html/head" position="inside">
<t t-if="website and website.google_tag_manager_key">
<!-- Google Tag Manager -->
<script type="text/javascript">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&amp;l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','<t t-esc="website.google_tag_manager_key" />');</script>
<!-- End Google Tag Manager -->
</t>
</xpath>
</template>

</odoo>
16 changes: 16 additions & 0 deletions website_google_tag_manager/views/website.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2016 ABF OSIELL <http://osiell.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>

<record id="view_website_form" model="ir.ui.view">
<field name="model">website</field>
<field name="inherit_id" ref="website.view_website_form" />
<field name="arch" type="xml">
<field name="google_analytics_key" position="after">
<field name="google_tag_manager_key" placeholder="GTM-XXXXX"/>
</field>
</field>
</record>

</odoo>
16 changes: 16 additions & 0 deletions website_google_tag_manager/views/website_config_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2016 ABF OSIELL <http://osiell.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>

<record id="view_website_config_settings" model="ir.ui.view">
<field name="model">website.config.settings</field>
<field name="inherit_id" ref="website.view_website_config_settings" />
<field name="arch" type="xml">
<div name="google_analytics_key" position="after">
<field name="google_tag_manager_key" placeholder="GTM-XXXXX"/>
</div>
</field>
</record>

</odoo>