Git Product home page Git Product logo

sylius-google-tag-manager-enhanced-ecommerce-plugin's Introduction

Google Tag Manager Enhanced Ecommerce plugin for Sylius eCommerce platform

License Version Build

Installation

1. Composer

composer require stefandoorn/sylius-google-tag-manager-enhanced-ecommerce-plugin

2. Follow installation instructions of required sub bundle

https://github.com/stefandoorn/google-tag-manager-plugin

3. Load bundle

Add to bundles.php:

StefanDoorn\SyliusGtmEnhancedEcommercePlugin\SyliusGtmEnhancedEcommercePlugin::class => ['all' => true],

4. Adjust configurations

Configure the features you would like to use/not. Find a base configuration reference by running:

bin/console config:dump-reference SyliusGtmEnhancedEcommercePlugin

By default all features are enabled.

Features

References + examples of how to set-up your GTM container: https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtm

Supported events:

  • view_item
  • view_item_list
  • add_to_cart
  • remove_from_cart
  • view_cart
  • begin_checkout
  • add_shipping_info
  • add_payment_info
  • purchase

Make sure to check that the required 'sonata_block_render_events' template events are available. Check the src/Resources/config/features/*.yml & src/Resources/config/services.yml for the definitions.

This is only to be checked if you've been overriding templates yourselves.

sylius-google-tag-manager-enhanced-ecommerce-plugin's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar dnna avatar dsbe-ak avatar kgonella avatar lruozzi9 avatar othbert avatar pamil avatar prometee avatar reyostallenberg avatar sbarbat avatar stefandoorn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sylius-google-tag-manager-enhanced-ecommerce-plugin's Issues

gtm.enhancedEcommerce errors

I get javascript error to all sites.
[Error] Failed to load resource: the server responded with a status of 500 ()
xxxxxx.....syliusgtmenhancedecommerceplugin/gtm.enhancedEcommerce.checkout.js
xxxxxx.....syliusgtmenhancedecommerceplugin/gtm.enhancedEcommerce.productClicks.js
xxxxxx.....syliusgtmenhancedecommerceplugin/gtm.enhancedEcommerce.cart.js
xxxxxx...../gtmplugin/prototype.events.js

Any idea how to solve this?

Please rename the plugin to something relate with sylius.

Firstly, Thank you for your great work.

But The name "google-tag-manager-enhanced-ecommerce-plugin" make a little confuse. Please rename it to something relate with Sylius.

It will help other people easy find this plugin and easy recognize it when read the title ( a plugin for sylius). Thanks

Add ability to choose the productIdentifier field

As the official documentation mention it, the 'id' field passed to the data layer can be a product ID or a SKU and should be typed as a string. This data is then displayed in various GA report like this one.

image

Some marketing team that works only in Sylius can use the product ID as product identifier. But when you have your shop connected to other internal product (ERP / PIM / Whatever...) you will need to work with a global identifier.

The product identifier is actually hardcoded in many files of the plugins. I think we can let the user choose which product identifier choose between Product ID (Sylius Product ID) and SKU (Sylius Product Code) in the configuration of the plugin. For instance, the default configuration should be Sylius Product ID to avoid any BC break.

ProductDetailImpression is sending all product variants to Google instead of just current selected variant

Preconditions:

  • you have a fresh new Sylius instance with dummy data installed
  • you have this plugin installed and activated
  • there are products with multiple variants (preferably, variants generated based on product options)

Steps to reproduce:

  1. open such a product page
  2. observe dataLayer

What happens:

  1. on a simple page load, all product variants are being sent a viewed to Google Tag Manager
  2. This will inflate the number of product pageviews artificially; the store owner will think visitors viewed all product variants for each product detail pageview, which is not true; also, depending on how Google Tag Manager is set, this might affect bounce rate as well

What should happen:

  1. only the current variant should be sent to Google
  2. when a visitor changes the variant, it should trigger again this tag and it should send another product detail event

On this page:
image

I have this dataLayer event:

{
    "ecommerce": {
        "currencyCode": "USD",
        "detail": [
            {
                "category": "Men",
                "id": "14",
                "name": "911M regular fit jeans",
                "price": 19.4,
                "variant": "911M_regular_fit_jeans-variant-0"
            },
            {
                "category": "Men",
                "id": "14",
                "name": "911M regular fit jeans",
                "price": 20.95,
                "variant": "911M_regular_fit_jeans-variant-1"
            },
            {
                "category": "Men",
                "id": "14",
                "name": "911M regular fit jeans",
                "price": 81.79,
                "variant": "911M_regular_fit_jeans-variant-2"
            },
            {
                "category": "Men",
                "id": "14",
                "name": "911M regular fit jeans",
                "price": 59.85,
                "variant": "911M_regular_fit_jeans-variant-3"
            },
            {
                "category": "Men",
                "id": "14",
                "name": "911M regular fit jeans",
                "price": 83.07,
                "variant": "911M_regular_fit_jeans-variant-4"
            }
        ]
    },
    "event": "productDetails"
}

Though I should have only this:

{
    "ecommerce": {
        "currencyCode": "USD",
        "detail": [
            {
                "category": "Men",
                "id": "14",
                "name": "911M regular fit jeans",
                "price": 19.4,
                "variant": "911M_regular_fit_jeans-variant-0"
            }
        ]
    },
    "event": "productDetails"
}

And if the visitor changes the variant to M, for example, another event like the one below should be fired:

{
    "ecommerce": {
        "currencyCode": "USD",
        "detail": [
            {
                "category": "Men",
                "id": "14",
                "name": "911M regular fit jeans",
                "price": 20.95,
                "variant": "911M_regular_fit_jeans-variant-1"
            }
    },
    "event": "productDetails"
}

Purchase sent to GA even for not paid order

Is it correct to push to GA all orders, even those that are not paid? The "purchase" event is, actually, fired when the user lands on the thank you page, without checking the state of the payment for the order. Maybe the payment failed but the order has already been created so the user land on the thank you page, and then he can retry the payment from the my account.

Wrong typehint in ProductDetail::setCategory

Argument 1 passed to StefanDoorn\SyliusGtmEnhancedEcommercePlugin\Object\ProductDetail::setCategory() must be of the type string, null given, called in ...vendor/stefandoorn/sylius-google-tag-manager-enhanced-ecommerce-plugin/src/Resolver/ProductDetailImpressionDataResolver.php on line 69

I'm getting this error, for having products without a Main Category in the Taxonomy. But that is not a required field by the default setup of Sylius. I think this field should be nullable. Or do you think there must be another solution done? I'm willing to help or make a PR

Handle clear cart button

In case of the customer use the clear button, the removeFromCart event should be sended for all product that were in the cart.

[Feature] Add a way to configure CHECKOUT_STEP_* js vars

I add another step to the checkout, name my steps in GA but I have to completely override Resources/views/Checkout/javascripts.html.twig to specify my own steps.

Maybe we can build a configuration here to specifysteps like this :

# config/packages/gtm_enhanced_ecommerce.yaml

gtm_enhanced_ecommerce:
  checkout: #  note: also keep the actual boolean value
    enable: true
    steps:
      2: "form[name=app_checkout_select_custom_something]"
      3: "form[name=sylius_checkout_address]"
      4: "form[name=sylius_checkout_select_shipping]"
      5: "form[name=sylius_checkout_select_payment]"

or a more complicated one :

# config/packages/gtm_enhanced_ecommerce.yaml

gtm_enhanced_ecommerce:
  checkout: #  note: also keep the actual boolean value
    enable: true
    steps:
      1:
        - event: "click"
          selector: "a[href$=/checkout/]"
      2:
        - event: "submit"
          selector: "form[name=app_checkout_select_custom_something]"
      3:
        - event: "submit"
          selector: "form[name=sylius_checkout_address]"
      4:
        - event: "submit"
          selector: "form[name=sylius_checkout_select_shipping]"
      5:
        - event: "submit"
          selector: "form[name=sylius_checkout_select_payment]"

Make plugin compatible with new Sylius template events

This plugin is relying on the Sonata blocks implementation for events in Sylius templates. would you consider upgrading to take advantage of Sylius/Sylius#10997 or rather deprecate this bundle and allow another one from the community to take over this on the long run, once Sonata blocks are removed from Sylius?

AddtoCart and RemovefromCart not working on default install of store

We discovered your plugin and have tried it out using a default installation of Sylius v1.8.12 with demo data.

We installed GTM Bundle v.2.8.0
We installed your GTM plugin v0.5.0
We installed your GTM EE plugin v0.10.0

This is the demo site with your plugin installed:

https://syliusdemo.onproof.net/

We installed the bootstrap GTM container.
We found that AddtoCart and RemovefromCart don’t get triggered.

https://github.com/stefandoorn/sylius-google-tag-manager-enhanced-ecommerce-plugin/blob/master/docs/cart.md
We tried the configs here for AddtoCart and RemovefromCart

The AddtoCart event is not sent to GTM, only gtm.click for the add to cart button.
Should this be working, or are we missing something?

Does upgrade.md show wrong namespace?

We need to override AddTransaction in TagManager.
Followed upgrade instructions from 0.6.0 to 0.8.0 at:
sylius-google-tag-manager-enhanced-ecommerce-plugin/UPGRADE.md

Specifically:

  • Rename namespace from GtmEnhancedEcommercePlugin to StefanDoorn\GtmEnhancedEcommercePlugin

Shouldn't the namespace be different?
from: GtmEnhancedEcommercePlugin to: StefanDoorn\SyliusGtmEnhancedEcommercePlugin

Thanks!

Use the hierarchical data in Category

As shown into the official documentation GA accept some hierarchical data in the Category field

Example :
Instead of : Men
Send : Category/T-shirts/Men

It help GA to aggregate all the Enhance Ecommerce Data.

It could be done by using the $taxon->getFullname('/') instead of $taxon->getName() in ProductDetailImpressionDataResolver.php and CreateProductTrait.php

Possible NullPointer in ViewItem

In StefanDoorn\SyliusGtmEnhancedEcommercePlugin\TagManager\ViewItem::addViewItemData
$this->productVariantResolver->getVariant($product) (line 65) can return null (if no variants are enabled)
which will make the calculate fail, because the parameter is null.

assets install directory

For sylius 1.10 the assets are installed only in the following directories after calling bin/console sylius:theme:assets:install:

public/bundles/gtmplugin/prototype.events.js
public/bundles/syliusgtmenhancedecommerceplugin/gtm.enhancedEcommerce.cart.js
public/bundles/syliusgtmenhancedecommerceplugin/gtm.enhancedEcommerce.checkout.js
public/bundles/syliusgtmenhancedecommerceplugin/gtm.enhancedEcommerce.productClicks.js

But the asset files are loaded from the _themes directory:

public/_themes/{theme-name}/bundles/gtmplugin/prototype.events.js
public/_themes/{theme-name}/bundles/syliusgtmenhancedecommerceplugin/gtm.enhancedEcommerce.cart.js
public/_themes/{theme-name}/bundles/syliusgtmenhancedecommerceplugin/gtm.enhancedEcommerce.checkout.js
public/_themes/{theme-name}/bundles/syliusgtmenhancedecommerceplugin/gtm.enhancedEcommerce.productClicks.js

Unfortunately the _themes directory is missing (maybe caused by Sylius/SyliusThemeBundle#91 ?)

Is there any way to fix this? Maybe by adding a fallback to the bundles directory, if the _themes directory does not exist?
Or is this something that can only be fixed in the Sylius/SyliusThemeBundle?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.