diff --git a/google_analytics_odoo/README.rst b/google_analytics_odoo/README.rst new file mode 100755 index 000000000..c116d6677 --- /dev/null +++ b/google_analytics_odoo/README.rst @@ -0,0 +1,46 @@ +.. image:: https://img.shields.io/badge/license-LGPL--3-green.svg + :target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 + +All In One Google Analytics +============================= +* Integrating Odoo with Google Analytics allows businesses to track user interactions and events within the Odoo application and send that data to their Google Analytics account + +Configuration +============= +* No additional configurations needed + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +Lesser General Public License, Version 3 (LGPL v3). +(https://www.gnu.org/licenses/lgpl-3.0-standalone.html) + +Credits +------- +Developer: (V16) Gokul P I , Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ diff --git a/google_analytics_odoo/__init__.py b/google_analytics_odoo/__init__.py new file mode 100755 index 000000000..9e5f5ab1d --- /dev/null +++ b/google_analytics_odoo/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import controllers +from . import models diff --git a/google_analytics_odoo/__manifest__.py b/google_analytics_odoo/__manifest__.py new file mode 100755 index 000000000..fe38f4016 --- /dev/null +++ b/google_analytics_odoo/__manifest__.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +{ + 'name': 'All In One Google Analytics', + 'version': '16.0.1.0.0', + 'category': 'Productivity', + 'summary': 'By connecting Google Analytics to Odoo and tracking relevant ' + 'events, you can make data-driven decisions, improve user' + 'experience, and enhance the overall performance of your ' + 'application.', + 'description': 'Integrating Odoo with Google Analytics allows businesses to' + 'track user interactions and events within the Odoo ' + 'application and send that data to their Google Analytics ' + 'account.This integration empowers businesses to improve ' + 'user experience and overall application performance.', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['website_sale', 'purchase', 'sale_management'], + 'data': [ + 'views/gtag_templates.xml', + 'views/res_config_settings_views.xml', + ], + 'assets': { + 'web.assets_frontend': [ + 'google_analytics_odoo/static/src/js/add_to_cart.js', + 'google_analytics_odoo/static/src/js/signup.js', + 'google_analytics_odoo/static/src/js/wishlist.js', + 'google_analytics_odoo/static/src/js/login.js', + 'google_analytics_odoo/static/src/js/checkout.js', + 'google_analytics_odoo/static/src/js/paynow.js', + ], + 'web.assets_backend': [ + 'google_analytics_odoo/static/src/js/backend.js', + ] + }, + 'images': [ + 'static/description/banner.png', + ], + 'license': 'LGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/google_analytics_odoo/controllers/__init__.py b/google_analytics_odoo/controllers/__init__.py new file mode 100755 index 000000000..22b956046 --- /dev/null +++ b/google_analytics_odoo/controllers/__init__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import account_move +from . import google_analytics_odoo +from . import payment_details +from . import product_details +from . import purchase_order +from . import sale_order diff --git a/google_analytics_odoo/controllers/account_move.py b/google_analytics_odoo/controllers/account_move.py new file mode 100644 index 000000000..2147878f5 --- /dev/null +++ b/google_analytics_odoo/controllers/account_move.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import http +from odoo.http import request + + +class InvoiceDetails(http.Controller): + """ This class contains + functions for getting invoice details. + Methods: + get_invoice_details(): + Returns the invoice details when confirming the invoice""" + + @http.route('/invoice_analytics', type="json", auth="public") + def invoice_details(self, **kw): + """ Returns the invoice details""" + order = request.env['account.move'].browse( + int(kw.get('order_id'))).read() + return { + 'invoice_data': {'name': order[0].get('name'), + 'amount': order[0].get('amount_total'), + 'customer': order[0].get('partner_id')[1]}, + } diff --git a/google_analytics_odoo/controllers/google_analytics_odoo.py b/google_analytics_odoo/controllers/google_analytics_odoo.py new file mode 100755 index 000000000..8a5221d3b --- /dev/null +++ b/google_analytics_odoo/controllers/google_analytics_odoo.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import http +from odoo.http import request +from odoo.addons.web.controllers import home + + +class GoogleAnalytics(home.Home): + """This class is inheriting the controller web and add a + Method + Methods: + google_analytics(): + Returns the Measurement id and api secret""" + + @http.route('/analytics', type="json", auth="public") + def google_analytics(self): + """Returns the Measurement id and api secret""" + return { + 'measurement_id': request.env[ + 'ir.config_parameter'].sudo().get_param( + 'google_analytics_odoo.measurement_id_analytics'), + 'api_secret': request.env['ir.config_parameter'].sudo().get_param( + 'google_analytics_odoo.api_secret'), + 'enable_analytics': request.env[ + 'ir.config_parameter'].sudo().get_param( + 'google_analytics_odoo.enable_analytics'), + } + diff --git a/google_analytics_odoo/controllers/payment_details.py b/google_analytics_odoo/controllers/payment_details.py new file mode 100644 index 000000000..271578af5 --- /dev/null +++ b/google_analytics_odoo/controllers/payment_details.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import http +from odoo.http import request + + +class PaymentDetails(http.Controller): + """ This class contains + functions for getting Payment details. + Methods: + get_payment_details(); + Returns the payment details when a customer pays + through the website""" + + @http.route('/get_payment_details', type="json", auth="public") + def get_payment_details(self, payments): + """ Returns the payment details""" + return { + 'payment': request.env['payment.provider'].sudo().browse( + int(payments['payment_option_id'])).name, + 'amount': payments['amount'], + 'partner': request.env['res.partner'].sudo().browse( + int(payments['partner_id'])).name + } diff --git a/google_analytics_odoo/controllers/product_details.py b/google_analytics_odoo/controllers/product_details.py new file mode 100644 index 000000000..a418ba6e3 --- /dev/null +++ b/google_analytics_odoo/controllers/product_details.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import http +from odoo.http import request + + +class ProductDetails(http.Controller): + """This class It contains + functions for getting the product details. + Methods: + get_product_details(): + Returns the product details for sending the events to + Analytics through js """ + @http.route('/product_analytics', type="json", auth="public") + def product_details(self, **kw): + """Returns the product details""" + return request.env['product.product'].sudo().browse( + int(kw.get('product_id'))).read() diff --git a/google_analytics_odoo/controllers/purchase_order.py b/google_analytics_odoo/controllers/purchase_order.py new file mode 100644 index 000000000..e21e7f39a --- /dev/null +++ b/google_analytics_odoo/controllers/purchase_order.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import http +from odoo.http import request + + +class PurchaseDetails(http.Controller): + @http.route('/purchase_analytics', type="json", auth="public") + def purchase_details(self, **kw): + """Returns the purchase order details""" + order = request.env['purchase.order'].browse( + int(kw.get('order_id'))).read() + return { + 'purchase_data': {'name': order[0].get('name'), + 'amount': order[0].get('amount_total'), + 'customer': order[0].get('partner_id')[1]} + } diff --git a/google_analytics_odoo/controllers/sale_order.py b/google_analytics_odoo/controllers/sale_order.py new file mode 100644 index 000000000..bb80d1869 --- /dev/null +++ b/google_analytics_odoo/controllers/sale_order.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import http +from odoo.http import request + + +class SalesDetails(http.Controller): + """This class It contains + functions for getting the sale order details. + Methods: + get_order_details(): + Returns the Sale order details when confirming the + purchase order """ + + @http.route('/sale_analytics', type="json", auth="public") + def sales_details(self, **kw): + """Returns the Sale order details""" + order = request.env['sale.order'].browse( + int(kw.get('order_id'))).read() + product_data = [] + for rec in request.env['sale.order'].browse( + int(kw.get('order_id'))).mapped('order_line'): + lines = request.env['sale.order.line'].browse(int(rec)) + product_data.append({ + 'product_name': lines.name, + 'price': lines.price_unit, + 'quantity': lines.product_uom_qty, + 'total_price': lines.price_total, + }) + return { + 'sales_data': {'name': order[0].get('name'), + 'amount': order[0].get('amount_total'), + 'customer': order[0].get('partner_id')[1]}, + 'product_data': product_data + } diff --git a/google_analytics_odoo/doc/RELEASE_NOTES.md b/google_analytics_odoo/doc/RELEASE_NOTES.md new file mode 100755 index 000000000..2fa414654 --- /dev/null +++ b/google_analytics_odoo/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 18.11.2023 +#### Version 16.0.1.0.0 +#### ADD +- Initial commit for All In One Google Analytics diff --git a/google_analytics_odoo/models/__init__.py b/google_analytics_odoo/models/__init__.py new file mode 100755 index 000000000..c989102fb --- /dev/null +++ b/google_analytics_odoo/models/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import res_config_settings diff --git a/google_analytics_odoo/models/res_config_settings.py b/google_analytics_odoo/models/res_config_settings.py new file mode 100755 index 000000000..f09039865 --- /dev/null +++ b/google_analytics_odoo/models/res_config_settings.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + """This class is inheriting the model 'product.product', It contains + fields and functions for the model. + Methods: + get_analytics_details(): + Returns the Analytics details """ + _inherit = 'res.config.settings' + + measurement_id_analytics = fields.Char( + config_parameter= + 'google_analytics_odoo.measurement_id_analytics', + string='Measurement ID', + help='Measurement id of the google analytics') + api_secret = fields.Char( + config_parameter= + 'google_analytics_odoo.api_secret', + string='API Secret', + help='API secret of the google analytics') + enable_analytics = fields.Boolean(config_parameter= + 'google_analytics_odoo.enable_analytics', + string='Enable Analytics', + help='Enable to send events to' + 'google analytics') + + def get_analytics_details(self): + """Returns the Google Analytics details """ + return { + 'measurement_id': self.env['ir.config_parameter'].sudo().get_param( + 'google_analytics_odoo.measurement_id_analytics'), + 'api_secret': self.env['ir.config_parameter'].sudo().get_param( + 'google_analytics_odoo.api_secret'), + 'enable_analytics': self.env[ + 'ir.config_parameter'].sudo().get_param( + 'google_analytics_odoo.enable_analytics'), + 'user': self.env.user.name + } diff --git a/google_analytics_odoo/static/description/assets/icons/check.png b/google_analytics_odoo/static/description/assets/icons/check.png new file mode 100755 index 000000000..c8e85f51d Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/check.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/chevron.png b/google_analytics_odoo/static/description/assets/icons/chevron.png new file mode 100755 index 000000000..2089293d6 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/chevron.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/cogs.png b/google_analytics_odoo/static/description/assets/icons/cogs.png new file mode 100755 index 000000000..95d0bad62 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/cogs.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/consultation.png b/google_analytics_odoo/static/description/assets/icons/consultation.png new file mode 100755 index 000000000..8319d4baa Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/consultation.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/ecom-black.png b/google_analytics_odoo/static/description/assets/icons/ecom-black.png new file mode 100755 index 000000000..a9385ff13 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/ecom-black.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/education-black.png b/google_analytics_odoo/static/description/assets/icons/education-black.png new file mode 100755 index 000000000..3eb09b27b Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/education-black.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/hotel-black.png b/google_analytics_odoo/static/description/assets/icons/hotel-black.png new file mode 100755 index 000000000..130f613be Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/hotel-black.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/license.png b/google_analytics_odoo/static/description/assets/icons/license.png new file mode 100755 index 000000000..a5869797e Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/license.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/lifebuoy.png b/google_analytics_odoo/static/description/assets/icons/lifebuoy.png new file mode 100755 index 000000000..658d56ccc Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/lifebuoy.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/manufacturing-black.png b/google_analytics_odoo/static/description/assets/icons/manufacturing-black.png new file mode 100755 index 000000000..697eb0e9f Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/manufacturing-black.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/pos-black.png b/google_analytics_odoo/static/description/assets/icons/pos-black.png new file mode 100755 index 000000000..97c0f90c1 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/pos-black.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/puzzle.png b/google_analytics_odoo/static/description/assets/icons/puzzle.png new file mode 100755 index 000000000..65cf854e7 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/puzzle.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/restaurant-black.png b/google_analytics_odoo/static/description/assets/icons/restaurant-black.png new file mode 100755 index 000000000..4a35eb939 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/restaurant-black.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/service-black.png b/google_analytics_odoo/static/description/assets/icons/service-black.png new file mode 100755 index 000000000..301ab51cb Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/service-black.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/trading-black.png b/google_analytics_odoo/static/description/assets/icons/trading-black.png new file mode 100755 index 000000000..9398ba2f1 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/trading-black.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/training.png b/google_analytics_odoo/static/description/assets/icons/training.png new file mode 100755 index 000000000..884ca024d Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/training.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/update.png b/google_analytics_odoo/static/description/assets/icons/update.png new file mode 100755 index 000000000..ecbc5a01a Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/update.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/user.png b/google_analytics_odoo/static/description/assets/icons/user.png new file mode 100755 index 000000000..6ffb23d9f Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/user.png differ diff --git a/google_analytics_odoo/static/description/assets/icons/wrench.png b/google_analytics_odoo/static/description/assets/icons/wrench.png new file mode 100755 index 000000000..6c04dea0f Binary files /dev/null and b/google_analytics_odoo/static/description/assets/icons/wrench.png differ diff --git a/google_analytics_odoo/static/description/assets/misc/categories.png b/google_analytics_odoo/static/description/assets/misc/categories.png new file mode 100755 index 000000000..bedf1e0b1 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/misc/categories.png differ diff --git a/google_analytics_odoo/static/description/assets/misc/check-box.png b/google_analytics_odoo/static/description/assets/misc/check-box.png new file mode 100755 index 000000000..42caf24b9 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/misc/check-box.png differ diff --git a/google_analytics_odoo/static/description/assets/misc/compass.png b/google_analytics_odoo/static/description/assets/misc/compass.png new file mode 100755 index 000000000..d5fed8faa Binary files /dev/null and b/google_analytics_odoo/static/description/assets/misc/compass.png differ diff --git a/google_analytics_odoo/static/description/assets/misc/corporate.png b/google_analytics_odoo/static/description/assets/misc/corporate.png new file mode 100755 index 000000000..2eb13edbf Binary files /dev/null and b/google_analytics_odoo/static/description/assets/misc/corporate.png differ diff --git a/google_analytics_odoo/static/description/assets/misc/customer-support.png b/google_analytics_odoo/static/description/assets/misc/customer-support.png new file mode 100755 index 000000000..79efc72ed Binary files /dev/null and b/google_analytics_odoo/static/description/assets/misc/customer-support.png differ diff --git a/google_analytics_odoo/static/description/assets/misc/cybrosys-logo.png b/google_analytics_odoo/static/description/assets/misc/cybrosys-logo.png new file mode 100755 index 000000000..cc3cc0ccf Binary files /dev/null and b/google_analytics_odoo/static/description/assets/misc/cybrosys-logo.png differ diff --git a/google_analytics_odoo/static/description/assets/misc/features.png b/google_analytics_odoo/static/description/assets/misc/features.png new file mode 100755 index 000000000..b41769f77 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/misc/features.png differ diff --git a/google_analytics_odoo/static/description/assets/misc/logo.png b/google_analytics_odoo/static/description/assets/misc/logo.png new file mode 100755 index 000000000..478462d3e Binary files /dev/null and b/google_analytics_odoo/static/description/assets/misc/logo.png differ diff --git a/google_analytics_odoo/static/description/assets/misc/pictures.png b/google_analytics_odoo/static/description/assets/misc/pictures.png new file mode 100755 index 000000000..56d255fe9 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/misc/pictures.png differ diff --git a/google_analytics_odoo/static/description/assets/misc/pie-chart.png b/google_analytics_odoo/static/description/assets/misc/pie-chart.png new file mode 100755 index 000000000..426e05244 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/misc/pie-chart.png differ diff --git a/google_analytics_odoo/static/description/assets/misc/right-arrow.png b/google_analytics_odoo/static/description/assets/misc/right-arrow.png new file mode 100755 index 000000000..730984a06 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/misc/right-arrow.png differ diff --git a/google_analytics_odoo/static/description/assets/misc/star.png b/google_analytics_odoo/static/description/assets/misc/star.png new file mode 100755 index 000000000..2eb9ab29f Binary files /dev/null and b/google_analytics_odoo/static/description/assets/misc/star.png differ diff --git a/google_analytics_odoo/static/description/assets/misc/support.png b/google_analytics_odoo/static/description/assets/misc/support.png new file mode 100755 index 000000000..4f18b8b82 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/misc/support.png differ diff --git a/google_analytics_odoo/static/description/assets/misc/whatsapp.png b/google_analytics_odoo/static/description/assets/misc/whatsapp.png new file mode 100755 index 000000000..d513a5356 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/misc/whatsapp.png differ diff --git a/google_analytics_odoo/static/description/assets/modules/1.png b/google_analytics_odoo/static/description/assets/modules/1.png new file mode 100755 index 000000000..a3194264c Binary files /dev/null and b/google_analytics_odoo/static/description/assets/modules/1.png differ diff --git a/google_analytics_odoo/static/description/assets/modules/2.png b/google_analytics_odoo/static/description/assets/modules/2.png new file mode 100755 index 000000000..cbcc848e2 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/modules/2.png differ diff --git a/google_analytics_odoo/static/description/assets/modules/3.png b/google_analytics_odoo/static/description/assets/modules/3.png new file mode 100644 index 000000000..e894393ef Binary files /dev/null and b/google_analytics_odoo/static/description/assets/modules/3.png differ diff --git a/google_analytics_odoo/static/description/assets/modules/4.png b/google_analytics_odoo/static/description/assets/modules/4.png new file mode 100755 index 000000000..83e33258b Binary files /dev/null and b/google_analytics_odoo/static/description/assets/modules/4.png differ diff --git a/google_analytics_odoo/static/description/assets/modules/5.gif b/google_analytics_odoo/static/description/assets/modules/5.gif new file mode 100755 index 000000000..beb106101 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/modules/5.gif differ diff --git a/google_analytics_odoo/static/description/assets/modules/6.png b/google_analytics_odoo/static/description/assets/modules/6.png new file mode 100644 index 000000000..eb3f8652f Binary files /dev/null and b/google_analytics_odoo/static/description/assets/modules/6.png differ diff --git a/google_analytics_odoo/static/description/assets/screenshots/analytics1.png b/google_analytics_odoo/static/description/assets/screenshots/analytics1.png new file mode 100644 index 000000000..b9a7d56dc Binary files /dev/null and b/google_analytics_odoo/static/description/assets/screenshots/analytics1.png differ diff --git a/google_analytics_odoo/static/description/assets/screenshots/analytics2.png b/google_analytics_odoo/static/description/assets/screenshots/analytics2.png new file mode 100644 index 000000000..a26312c6b Binary files /dev/null and b/google_analytics_odoo/static/description/assets/screenshots/analytics2.png differ diff --git a/google_analytics_odoo/static/description/assets/screenshots/analytics3.png b/google_analytics_odoo/static/description/assets/screenshots/analytics3.png new file mode 100644 index 000000000..0ccaac42a Binary files /dev/null and b/google_analytics_odoo/static/description/assets/screenshots/analytics3.png differ diff --git a/google_analytics_odoo/static/description/assets/screenshots/analytics4.png b/google_analytics_odoo/static/description/assets/screenshots/analytics4.png new file mode 100644 index 000000000..60574488c Binary files /dev/null and b/google_analytics_odoo/static/description/assets/screenshots/analytics4.png differ diff --git a/google_analytics_odoo/static/description/assets/screenshots/analytics5.png b/google_analytics_odoo/static/description/assets/screenshots/analytics5.png new file mode 100644 index 000000000..61a48ad27 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/screenshots/analytics5.png differ diff --git a/google_analytics_odoo/static/description/assets/screenshots/analytics6.png b/google_analytics_odoo/static/description/assets/screenshots/analytics6.png new file mode 100644 index 000000000..7c7089581 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/screenshots/analytics6.png differ diff --git a/google_analytics_odoo/static/description/assets/screenshots/conf.png b/google_analytics_odoo/static/description/assets/screenshots/conf.png new file mode 100644 index 000000000..2e5e5ab15 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/screenshots/conf.png differ diff --git a/google_analytics_odoo/static/description/assets/screenshots/hero.gif b/google_analytics_odoo/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..c299fcfc5 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/screenshots/hero.gif differ diff --git a/google_analytics_odoo/static/description/assets/screenshots/realtime.png b/google_analytics_odoo/static/description/assets/screenshots/realtime.png new file mode 100644 index 000000000..268952a25 Binary files /dev/null and b/google_analytics_odoo/static/description/assets/screenshots/realtime.png differ diff --git a/google_analytics_odoo/static/description/banner.png b/google_analytics_odoo/static/description/banner.png new file mode 100644 index 000000000..4cbd93d98 Binary files /dev/null and b/google_analytics_odoo/static/description/banner.png differ diff --git a/google_analytics_odoo/static/description/icon.png b/google_analytics_odoo/static/description/icon.png new file mode 100644 index 000000000..ebdfd1fe0 Binary files /dev/null and b/google_analytics_odoo/static/description/icon.png differ diff --git a/google_analytics_odoo/static/description/index.html b/google_analytics_odoo/static/description/index.html new file mode 100755 index 000000000..54ec04533 --- /dev/null +++ b/google_analytics_odoo/static/description/index.html @@ -0,0 +1,711 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+ Odoo SH +
+
+
+ +
+ +

+ All In One Google Analytics

+

+ Google Analytics Allows You To Track User Interactions And Events + Within Your Odoo Application And Send That Data To Your + Google Analytics Account For Analysis

+ + +
+ +
+ + +
+
+ +
+

+ Explore This + Module

+
+ + + + +
+
+ +
+

+ Overview +

+
+
+
+ The Google Analytics module in Odoo enables businesses to integrate + Google Analytics with their Odoo backend and website. It tracks various + events and actions, such as confirming sale orders, purchase orders, + and invoices in the backend. Additionally, it monitors actions like + adding items to the cart, wishlist, user logins, sign-ups, and product + payments on the website. By leveraging this module, businesses can gain + valuable insights into user behavior, optimize processes, and improve + the overall website experience. + + Please note that Some Website events like Add to Cart ,login ,sign + up is not working when you are using incognito mode in firefox browser. + +
+ +
+ + + +
+
+ +
+

+ Features +

+
+
+
+
+ + Event Tracking: The module can send events to Google Analytics when specific actions occur in the Odoo backend, such as confirming a sale order, purchase order, or invoice. This data helps you understand how your business processes are performing and make data-driven decisions. +
+
+ + E-commerce Tracking: For your website, the module can track important e-commerce actions, such as adding products to the cart or wishlist. This data enables you to analyze user behavior, identify popular products, and optimize your website's user experience. +
+
+ + User Engagement Tracking: The module tracks user logins and sign-ups on your website. This data provides insights into user engagement, user acquisition, and helps you understand your customer base better. +
+
+
+
+ + Payment Tracking: The module can track product payments made on your website. This data allows you to analyze the effectiveness of your payment methods and gain insights into your revenue generation. +
+
+ + Compatible with both Odoo 16.0 Community and Enterprise Editions. +
+
+
+ + + +
+
+ +
+

+ Screenshots +

+
+
+
+ +
+

+ Google Analytics View

+

+ First goto https://analytics.google.com/ + --> ADMIN --> Data + Streams

+ +
+
+

+ Then select Add stream -->Web

+ +
+
+ +

+ Then add the valid Website URL + (odoo instance) and Stream name and Create stream

+ +
+
+ +

+ After that you can see your stream in data stream and copy the + 'MEASUREMENT ID' from there

+ +
+
+ +

+ After that you can create API secret in 'Measurement Protocol + API secrets' option

+ +
+
+ +

+ Create the API secret and copy the 'Secret value' from + there

+ +
+
+

+ Configuration Settings +

+

+ Goto the Settings and enable the 'Enable Analytics' then you + can set the 'Measurement ID' and 'API Secret'

+ + +
+ +
+

+ Realtime View in Google Analytics

+

+ After performing certain actions in the Odoo backend, like + confirming a sale order, purchase order, or invoice, and also + when users add products to the cart or wishlist on the website, + or when they log in or sign up, you can view these events in + real-time using Google Analytics.

+ +
+
+
+ + + +
+
+ +
+

+ Related + Products +

+
+
+
+ +
+
+ + + + +
+
+ +
+

+ Our Services +

+
+ +
+
+
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+ +
+ + + + + +
+
+ +
+

+ Our + Industries +

+
+ +
+
+
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+ +
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+ +
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+ +
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+ +
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+ +
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+ +
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+ +
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

+
+
+
+
+ + + + +
+
+ +
+

+ Support +

+
+
+
+
+
+
+ +
+
+

Need Help?

+

Got questions or need help? + Get in touch.

+ +

+ odoo@cybrosys.com

+
+
+
+
+
+
+
+ +
+
+

WhatsApp

+

Say hi to us on WhatsApp!

+ +

+ +91 86068 + 27707

+
+
+
+
+
+
+
+ +
+
+
+ diff --git a/google_analytics_odoo/static/src/js/add_to_cart.js b/google_analytics_odoo/static/src/js/add_to_cart.js new file mode 100755 index 000000000..7c4e45e68 --- /dev/null +++ b/google_analytics_odoo/static/src/js/add_to_cart.js @@ -0,0 +1,52 @@ +/** @odoo-module **/ +import { WebsiteSale } from 'website_sale.website_sale'; +import ajax from 'web.ajax'; + +WebsiteSale.include({ + /** + * @Super the _onClickAdd function to send the event to the Analytics + */ + _onClickAdd: function(ev) { + this._super(...arguments); + var self = this; + if (ev.currentTarget.previousElementSibling) { + this.product_id = ev.currentTarget.previousElementSibling.value + } else { + this.product_id = this.last_product_id + } + ajax.jsonRpc("/product_analytics", 'call', {'product_id':this.product_id}).then(function(data) { + ajax.jsonRpc("/analytics", 'call', {}).then(function(datas) { + if (datas.enable_analytics) + { + self.measurement_id = datas.measurement_id; + self.api_secret = datas.api_secret; + if (self.measurement_id != false && self.api_secret != false) { + gtag('get', self.measurement_id, 'client_id', (clientID) => { + sendCartEvent(clientID, "AddToCart", data[0]) + }); + } + } + }); + // Sending the event to Google Analytics when the user adds a new + // product to the shopping cart. + function sendCartEvent(clientID, eventName, eventData) { + fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${self.measurement_id}&api_secret=${self.api_secret}`, { + method: "POST", + body: JSON.stringify({ + client_id: clientID, + events: [{ + name: 'Add_to_cart', + params: { + "currency": eventData['currency_id'][1], + "value": eventData['lst_price'], + "item_id": eventData['id'], + "item_name": eventData['display_name'], + "price": eventData['lst_price'], + } + }] + }) + }); + } + }); + } +}); diff --git a/google_analytics_odoo/static/src/js/backend.js b/google_analytics_odoo/static/src/js/backend.js new file mode 100755 index 000000000..dc27ff4a3 --- /dev/null +++ b/google_analytics_odoo/static/src/js/backend.js @@ -0,0 +1,125 @@ +/** @odoo-module **/ +import { FormController } from "@web/views/form/form_controller"; +import { patch } from "@web/core/utils/patch"; +const ajax = require('web.ajax'); + +//Patch the FormController to Send the Events to Google Analytics +//From the Backed +patch(FormController.prototype, "FormController.google", { + //Super the setup Function + setup() { + this._super.apply(this, arguments); + }, + //Override the afterExecuteActionButton function to send the evens + async afterExecuteActionButton(clickParams) { + var self = this; + await ajax.jsonRpc("/analytics", 'call', {}).then(function(data) { + self.measurement_id = data.measurement_id + self.api_secret = data.api_secret + self.enable_analytics=data.enable_analytics + }); + self.measurement_id = this.measurement_id; + self.api_secret = this.api_secret; + self.enable_analytics = this.enable_analytics + if (self.enable_analytics) + { + if (self.measurement_id != false && self.api_secret != false) { + if (clickParams.name === "action_confirm" && this.props.resModel === "sale.order") { + var order_id = this.model.root.data.id + var self = this + ajax.jsonRpc("/sale_analytics", 'call', {'order_id':order_id}).then(function(data) { + gtag('get', self.measurement_id, 'client_id', (clientID) => { + sendSaleEvent(clientID, "Sales", data['sales_data']) + }); + // Sending the event to Google Analytics when confirming + // Sale order. + function sendSaleEvent(clientID, eventName, eventData) { + fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${self.measurement_id}&api_secret=${self.api_secret}`, { + method: "POST", + body: JSON.stringify({ + client_id: clientID, + events: [{ + name: 'Sales_Order', + params: { + "Number": String(eventData.name), + "Customer": String(eventData.customer), + "Amount": String(eventData.amount), + } + }] + }) + }); + } + }); + } + if (clickParams.name === "button_confirm" && this.props.resModel === "purchase.order") { + var order_id = this.model.root.data.id + var self = this + ajax.jsonRpc("/purchase_analytics", 'call', {'order_id':order_id}).then(function(data) { + gtag('get', self.measurement_id, 'client_id', (clientID) => { + sendPurchaseEvent(clientID, "Purchase", data['purchase_data']) + }); + function sendPurchaseEvent(clientID, eventName, eventData) { + // Sending the event to Google Analytics when confirming + // Purchase order. + fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${self.measurement_id}&api_secret=${self.api_secret}`, { + method: "POST", + body: JSON.stringify({ + client_id: clientID, + events: [{ + name: 'purchase_order', + params: { + "Number": String(eventData.name), + "Customer": String(eventData.customer), + "Amount": String(eventData.amount), + } + }] + }) + }); + } + }); + } + if (clickParams.name === "action_post" && this.props.resModel === "account.move") { + var order_id = this.model.root.data.id + ajax.jsonRpc("/invoice_analytics", 'call', {'order_id':order_id}).then(function(data) { + gtag('get', self.measurement_id, 'client_id', (clientID) => { + sendInvoiceEvent(clientID, "addoAFF", data['invoice_data']) + }); + // Sending the event to Google Analytics when confirming + // Invoice. + function sendInvoiceEvent(clientID, eventName, eventData) { + fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${self.measurement_id}&api_secret=${self.api_secret}`, { + method: "POST", + body: JSON.stringify({ + client_id: clientID, + events: [{ + name: 'Invoices', + params: { + "Number": String(eventData.name), + "Customer": String(eventData.customer), + "Amount": String(eventData.amount), + } + }] + }) + }); + } + }); + } + if (clickParams.special !== "cancel") { + return this.model.root + .save({ + stayInEdition: true, + useSaveErrorDialog: !this.env.inDialog + }) + .then((saved) => { + if (saved && this.props.onSave) { + this.props.onSave(this.model.root); + } + return saved; + }); + } else if (this.props.onDiscard) { + this.props.onDiscard(this.model.root); + } + } + } + } +}); diff --git a/google_analytics_odoo/static/src/js/checkout.js b/google_analytics_odoo/static/src/js/checkout.js new file mode 100755 index 000000000..9773d9b19 --- /dev/null +++ b/google_analytics_odoo/static/src/js/checkout.js @@ -0,0 +1,45 @@ +odoo.define('google_analytics_odoo.checkout', function(require) { + var publicWidget = require('web.public.widget'); + const ajax = require('web.ajax'); + + publicWidget.registry.websiteSaleTracking = publicWidget.Widget.extend({ + selector: '.oe_website_sale', + events: { + 'click a[href="/shop/checkout?express=1"]': '_onCheckoutStarts', + }, + //When an user Checkout the cart then send the event to the Analytics + _onCheckoutStarts: function(ev) { + ajax.jsonRpc("/analytics", 'call', {}).then(function(data) { + if (data.enable_analytics){ + self.measurement_id = data.measurement_id; + self.api_secret = data.api_secret; + self.user = data.user + if (self.measurement_id != false && self.api_secret != false) { + gtag('get', self.measurement_id, 'client_id', (clientID) => { + sendOfflineEvent(clientID, "Checkout", data) + }); + } + } + }); + //Send the event to Google Analytics + function sendOfflineEvent(clientID, eventName, eventData) { + fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${self.measurement_id}&api_secret=${self.api_secret}`, { + method: "POST", + body: JSON.stringify({ + client_id: clientID, + events: [{ + name: 'Cart_checkout', + params: { + 'Checkout': 'checkout started by' + self.user + } + }] + }) + }); + } + }, + //Override the default _onCheckoutStart function + _onCheckoutStart: function() { + this._vpv('/stats/ecom/customer_checkout'); + }, + }); +}); diff --git a/google_analytics_odoo/static/src/js/login.js b/google_analytics_odoo/static/src/js/login.js new file mode 100755 index 000000000..15f40116a --- /dev/null +++ b/google_analytics_odoo/static/src/js/login.js @@ -0,0 +1,44 @@ +/** @odoo-module **/ +import publicWidget from 'web.public.widget'; +import ajax from 'web.ajax'; + +publicWidget.registry.login = publicWidget.Widget.extend({ + selector: '.oe_login_form', + events: { + 'click button[type="submit"]': '_onLogIn', + }, + /** + * @override the _onLogIn function to override the default workflow of login + */ + _onLogIn: async function(ev) { + var self = this; + await ajax.jsonRpc('/analytics', 'call', {}).then((result) => { + self.measurement_id = result.measurement_id + self.api_secret = result.api_secret + self.enable_analytics = result.enable_analytics + }); + if (self.enable_analytics){ + if (self.measurement_id != false && self.api_secret != false) { + gtag('get', self.measurement_id, 'client_id', (clientID) => { + sendLoginEvent(clientID, "LOGIN") + }); + var user = this.$("#login").val() + // Send the events to Analytics When a user is logged in + function sendLoginEvent(clientID, eventName) { + fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${self.measurement_id}&api_secret=${self.api_secret}`, { + method: "POST", + body: JSON.stringify({ + client_id: clientID, + events: [{ + name: 'User_login', + params: { + "User": user + } + }] + }) + }); + } + } + } + } +}); diff --git a/google_analytics_odoo/static/src/js/paynow.js b/google_analytics_odoo/static/src/js/paynow.js new file mode 100755 index 000000000..67bd9763d --- /dev/null +++ b/google_analytics_odoo/static/src/js/paynow.js @@ -0,0 +1,58 @@ +/** @odoo-module **/ +import core, { _t } from 'web.core'; +import checkoutForm from 'payment.checkout_form'; +import ajax from 'web.ajax'; + + +checkoutForm.include({ + /** + * @override _prepareTransactionRouteParams to send events to Analytics + */ + _prepareTransactionRouteParams: function(code, paymentOptionId, flow) { + const transactionRouteParams = this._super(...arguments); + var payment = $('.o_donation_payment_form').length ? { + ...transactionRouteParams, + 'partner_details': { + 'name': this.$('input[name="name"]').val(), + 'email': this.$('input[name="email"]').val(), + 'country_id': this.$('select[name="country_id"]').val(), + }, + 'donation_comment': this.$('#donation_comment').val(), + 'donation_recipient_email': this.$('input[name="donation_recipient_email"]').val(), + } : transactionRouteParams; + + + ajax.jsonRpc("/get_payment_details", 'call', {'payment':payment}).then(function(data) { + ajax.jsonRpc("/analytics", 'call', {}).then(function(datas) { + if (datas.enable_analytics){ + self.measurement_id = datas.measurement_id; + self.api_secret = datas.api_secret; + if (self.measurement_id != false && self.api_secret != false) { + gtag('get', self.measurement_id, 'client_id', (clientID) => { + sendCartEvent(clientID, "Payments", data) + }); + } + //Send the event to Google Analytics when the payments is + // processed in the website + function sendCartEvent(clientID, eventName, eventData) { + fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${self.measurement_id}&api_secret=${self.api_secret}`, { + method: "POST", + body: JSON.stringify({ + client_id: clientID, + events: [{ + name: 'Payments', + params: { + "customer": data.partner, + "payment_information": data.payment, + "amount": data.amount + } + }] + }) + }); + } + } + }); + }); + return payment + }, +}); diff --git a/google_analytics_odoo/static/src/js/signup.js b/google_analytics_odoo/static/src/js/signup.js new file mode 100755 index 000000000..39522baca --- /dev/null +++ b/google_analytics_odoo/static/src/js/signup.js @@ -0,0 +1,49 @@ +odoo.define('google_analytics_odoo.signup', function(require) { + 'use strict'; + + var publicWidget = require('web.public.widget'); + const ajax = require('web.ajax'); + + publicWidget.registry.SignUpForm = publicWidget.Widget.extend({ + selector: '.oe_signup_form', + events: { + 'submit': '_onSubmit', + }, + /** + * @override the _onSubmit function to override the default workflow of sign up + */ + _onSubmit: async function(ev) { + var self = this; + await ajax.jsonRpc('/analytics', 'call', {}).then((result) => { + self.measurement_id = result.measurement_id + self.api_secret = result.api_secret + self.enable_analytics = result.enable_analytics + }); + if (self.enable_analytics){ + if (self.measurement_id != false && self.api_secret != false) { + var user_name = this.$("#name").val() + var mail = this.$("#login").val() + gtag('get', self.measurement_id, 'client_id', (clientID) => { + sendSignupEvent(clientID, "SIGNUP") + }); + // Send the events to Analytics When a user is signed up + function sendSignupEvent(clientID, eventName) { + fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${self.measurement_id}&api_secret=${self.api_secret}`, { + method: "POST", + body: JSON.stringify({ + client_id: clientID, + events: [{ + name: 'Signup_user', + params: { + "Name": user_name, + "Mail": mail, + } + }] + }) + }); + } + } + } + }, + }); +}); diff --git a/google_analytics_odoo/static/src/js/wishlist.js b/google_analytics_odoo/static/src/js/wishlist.js new file mode 100755 index 000000000..f3d885859 --- /dev/null +++ b/google_analytics_odoo/static/src/js/wishlist.js @@ -0,0 +1,49 @@ + /** @odoo-module **/ +import publicWidget from 'web.public.widget'; +import 'website_sale_wishlist.wishlist'; +import ajax from 'web.ajax'; + +publicWidget.registry.ProductWishlist.include({ + /** + * Removes wishlist indication when adding a product to the wishlist. + * + * @override function to send the event to the Analytics + */ + _onClickAddWish: function(ev) { + this._super.apply(this, arguments); + if (ev.currentTarget.attributes[10]){ + var product_id = ev.currentTarget.attributes[10].value + ajax.jsonRpc("/product_analytics", 'call', {'product_id':this.product_id}).then(function(data) { + ajax.jsonRpc("/analytics", 'call', {}).then(function(datas) { + if (datas.enable_analytics){ + self.measurement_id = datas.measurement_id; + self.api_secret = datas.api_secret; + gtag('get', self.measurement_id, 'client_id', (clientID) => { + sendOfflineEvent(clientID, "AddToWishlist", data[0]) + }); + } + }); + // Sending the event to Google Analytics when the user adds a new + // product to the shopping cart. + function sendOfflineEvent(clientID, eventName, eventData) { + var send_data = fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${self.measurement_id}&api_secret=${self.api_secret}`, { + method: "POST", + body: JSON.stringify({ + client_id: clientID, + events: [{ + name: 'Add_to_wishlist', + params: { + "currency": eventData['currency_id'][1], + "value": eventData['lst_price'], + "item_id": eventData['id'], + "item_name": eventData['display_name'], + "price": eventData['lst_price'], + } + }] + }) + }); + } + }); + } + }, +}); diff --git a/google_analytics_odoo/views/gtag_templates.xml b/google_analytics_odoo/views/gtag_templates.xml new file mode 100755 index 000000000..2e3109dcf --- /dev/null +++ b/google_analytics_odoo/views/gtag_templates.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/google_analytics_odoo/views/res_config_settings_views.xml b/google_analytics_odoo/views/res_config_settings_views.xml new file mode 100755 index 000000000..8b1ed2806 --- /dev/null +++ b/google_analytics_odoo/views/res_config_settings_views.xml @@ -0,0 +1,52 @@ + + + + + + res.config.settings.view.form.inherit.google.analytics.odoo + + res.config.settings + + + + +

Google Analytics

+
+ +
+
+
+
+