FinalBitSW / ps-cwgecommerce

Prestashop module for sending data to Google Analytics and Adwords via Google Tag Manager.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Google E-commerce

About

Google E-commerce is a Prestashop module for sending data to Google Analytics and Google Adwords via Google Tag Manager. It tracks:

  • product impressions
  • product clicks
  • product detail impressions (trigger: product page view)
  • promotion impressions
  • promotion clicks
  • cart actions
  • checkout actions
  • Adwords conversion (trigger: order confirmation page view)
  • purchases (trigger: new order payment)
  • partial refunds (trigger: new order slip)
  • complete refund

3 tags, 2 triggers, and 3 variables must be created in Google Tag Manager (see Usage).

This module is currently used in production websites with Prestashop 1.6 and PHP 7+.

Installation

This module is best used with Composer managing your Prestashop project globally. This method follows best practices for managing external dependencies of a PHP project.

Create or edit composer.json in the Prestashop root directory:

"repositories": [
  {
    "type": "git",
    "url": "https://github.com/creativewave/ps-cwgecommerce"
  },
  {
    "type": "git",
    "url": "https://github.com/creativewave/ps-module-configuration"
  }
],
"require": {
  "creativewave/ps-cwmedia": "^1"
},

Then run composer update.

Usage

Google provides general support and developper support for using Google Tag Manager and configuring tracking with Google Analytics/Adwords.

But in short words, using Google Tag Manager boils down to create/use:

  • a container: an HTML <script> (injected by this module) with a function (IIFE) injecting tags
  • tags: third party (Google Analytics/Adwords) Javascript code
  • triggers: conditions checked by the container to decide which tags to inject
  • variables: dynamic data used by tags and/or triggers

Creating a Google Tag Manager container

  1. Log in to Google Tag Manager
  2. Create a new (Web) container
  3. Pick up container ID
  4. Save it in Prestashop > Modules > CWGEcommerce configuration

Tracking impressions, clicks, purchases and refunds (2 tags, 1 triggers)

Optional: a built in Google Analytics Settings (multi-)variable(s) may be created and used by the following tags, in order to ease changes on Google Analytics tracking settings.

  1. Create a new trigger custom event with a value orderUpdate (to track transactions and refunds)
  2. Create a new tag Universal Analytics with a Page view tracking type and built in trigger All Pages
  3. Create a new tag Universal Analytics with a Transaction tracking type and custom trigger orderUpdate

Tracking Google Adwords conversions (1 tag, 1 trigger, 3 variables)

3 variables should be created in order to feed Google Tag Manager with conversion data (order ID, value and currency) generated by this module in a data layer (Javascript object).

1 trigger should be created to ensure that an order (conversion) has happened. This trigger will correspond to a view of the order confirmation page.

Google Adwords should know which conversion happened by checking a conversion ID and label, available in Google Adwords after having created a new conversion action.

  1. Create a new variable data layer with a value google_conversion_order_id
  2. Create a new variable data layer with a value google_conversion_value
  3. Create a new variable data layer with a value google_conversion_currency
  4. Create a new trigger custom event with a value orderConfirmation
  5. Create a new tag Adwords Conversion Tracking
  6. Set conversion ID and label
  7. Set previously created variables as order ID, value and currency

Note: a Conversion Linker tag should also be created if your Google Analytics/Adwords accounts arn't associated, otherwise Safari will block conversion tracking.

Todo

  • Feature: track more data

About

Prestashop module for sending data to Google Analytics and Adwords via Google Tag Manager.

License:MIT License


Languages

Language:PHP 95.8%Language:Makefile 2.9%Language:Smarty 1.3%