Coder Social home page Coder Social logo

yireo_googletagmanager2's Introduction

Magento 2 module for Google Tag Manager

Also see: https://www.yireo.com/software/magento-extensions/googletagmanager2

Currently, the Yireo_GoogleTagManager2 module has been refactored heavily: The architecture is redesigned, GA4 support is being added, GA3 support (aka UA/EE) is being removed, click-events are added and overall there is a huge extensibility being added. The refactoring has come available under a new major version 3. If you were not using this extension yet, you can just proceed with the composer installation which will pick this new version. If you were using major version 2 in the past, edit your composer.json file manually to use the new version ^3.0. Alternatively, update your composer.json by using the command composer require yireo/magento2-googletagmanager2:^3.0 --no-update. Next, upgrade with composer update.

Latest Stable Version Total Downloads License

ExtDN Unit Tests ExtDN Static Tests ExtDN Integration Tests

Requirements

Supported versions: Magento 2.3.7 or higher and 2.4.1 or higher (partially because of the requirement for PHP 7.4 or PHP 8.1).

See composer.json for other requirements.

See also

yireo_googletagmanager2's People

Contributors

anthony-blackbird avatar bvmax avatar elioermini avatar frqnck avatar gaeldelmer avatar hans2103 avatar irinina avatar jemoon avatar jissereitsma avatar juulgr avatar koenner01 avatar lfolco avatar mecheverria89 avatar meminuygur avatar michielgerritsen avatar nicolas-medina avatar pgrigoruta avatar r4y7s avatar rajeev-k-tomy avatar renovate[bot] avatar samicoman avatar scribam avatar shwetawawale avatar sprankhub avatar stijntrinos avatar tdgroot avatar thomas-kl1 avatar timpea-splat avatar wahidnory avatar woutersteen 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yireo_googletagmanager2's Issues

Incorrect dependency error during compilation

Hey,

I'm having some issues when running the bin/magento setup:di:compile command on Magento 2.0.7. It gives me the following error:

Errors during compilation:
    Yireo\GoogleTagManager2\Block\Generic
        Incorrect dependency in class Yireo\GoogleTagManager2\Block\Generic in /data/web/magento2/app/code/Yireo/GoogleTagManager2/Block/Generic.php
\Magento\Framework\App\Config\ScopeConfigInterface already exists in context object
\Magento\Store\Model\StoreManagerInterface already exists in context object
\Magento\Framework\View\LayoutInterface already exists in context object
Total Errors Count: 1
Errors during compilation:
    Yireo\GoogleTagManager2\Block\Generic
        Incorrect dependency in class Yireo\GoogleTagManager2\Block\Generic in /data/web/magento2/app/code/Yireo/GoogleTagManager2/Block/Generic.php
\Magento\Framework\App\Config\ScopeConfigInterface already exists in context object
\Magento\Store\Model\StoreManagerInterface already exists in context object
\Magento\Framework\View\LayoutInterface already exists in context object
Total Errors Count: 1
Errors during compilation:
    Yireo\GoogleTagManager2\Block\Generic
        Incorrect dependency in class Yireo\GoogleTagManager2\Block\Generic in /data/web/magento2/app/code/Yireo/GoogleTagManager2/Block/Generic.php
\Magento\Framework\App\Config\ScopeConfigInterface already exists in context object
\Magento\Store\Model\StoreManagerInterface already exists in context object
\Magento\Framework\View\LayoutInterface already exists in context object
Total Errors Count: 1

I have already tried to remove and re-add the module using the composer remove and composer require commands. I have no idea what's going wrong here.

Thanks :)

How to manage google analytics

Hi
I need help how can I check if the google analytics is working in the magento 2 store if this extension is enabled. How to confirm if google analytics is working.

FPC issues when cookie restriction is enabled

When cookie restriction and full page cache is enabled in magento pages are sometimes cached without gtm code inside and then served to all users.
This happens when first time visitors open the page and therefore have cookie restriction and their visit is then cached. Subsequent visits from users that accepted the cookies are served from cache and also have no gtm.

Extension version: 1.0.1
Magento: 2.2.8

How to reproduce:

  1. Enable Full page cache (admin->system->cache management)
  2. Enable cookie restriction (admin->store->configuration->general->web->default cookie settings then set Cookie Restriction Mode to yes)
  3. Visit the in the frontend from incognito window (page A broser A)
  4. Open different page from frontend in a different browser (page B browser B)
  5. Accept cookies from cookie banner on the bottom of the page. (page B browser B)
  6. Open the first page with the second browser (page A browser B)

Expected result:
page A with browser A should have no gtm
page A browser B should have gtm

Actual result:
page A with both browsers have no gtm

on checkoutpage the dalayer still get "Quote"

Hi,
First thanks for that module.

I tested it on a clean install of magento 2.2.2 with defaut theme and sample data.

The datalayer contain all needed data, but when I validate the order and get redirected to /checkout/onepage/success
The datalayer is still in "quote" mode.
I have to visit an other page to get it in "Order" mode.

After a quick review of "network" panel I see a request to
http://magento.test/customer/section/load/?sections=yireo-gtm-quote%2Cyireo-gtm-order&_=1518707232232 with the status "canceled"

If I submit this request by hand, the datalayer goes well in "order" mode.
But I can't figure why I got this status "canceled".
If you got any tip to help to debug it.
Thanks

yireoGoogleTagManager.min.js not found

Mode : production
delploy-content : done
JS minification : active
JS concatenation : active
Magento 2.2.1

When i load a page, i get a JS error :
https://mydomain.com/static/frontend/theme_vendor/theme_name/fr_FR/yireoGoogleTagManager.min.js returns a 404.
after checked, the file isn't there but there is a pub/static/frontend/theme_vendor/theme_name/fr_FR/Yireo_GoogleTagManager2/js/generic.min.js

and i guess this is this file which needs to be read.
How can i fix that ?
thanks

Magento setup:di:compile Error

I am suing magento 2.1.2 with MAMP and PHP7

If i run the following command:
Magento setup:di:compile

I obtain the following error

Compilation was started.
Interception cache generation...

Errors during compilation:
Yireo\GoogleTagManager2\Block\Category
Incorrect dependency in class Yireo\GoogleTagManager2\Block\Category in /Applications/MAMP/htdocs/magento2/app/code/Yireo/GoogleTagManager2/Block/Category.php
\Magento\Framework\App\Config\ScopeConfigInterface already exists in context object
\Magento\Store\Model\StoreManagerInterface already exists in context object
\Magento\Framework\View\LayoutInterface already exists in context object
Yireo\GoogleTagManager2\Block\Generic
Incorrect dependency in class Yireo\GoogleTagManager2\Block\Generic in /Applications/MAMP/htdocs/magento2/app/code/Yireo/GoogleTagManager2/Block/Generic.php
\Magento\Framework\App\Config\ScopeConfigInterface already exists in context object
\Magento\Store\Model\StoreManagerInterface already exists in context object
Yireo\GoogleTagManager2\Block\Order
Incorrect dependency in class Yireo\GoogleTagManager2\Block\Order in /Applications/MAMP/htdocs/magento2/app/code/Yireo/GoogleTagManager2/Block/Order.php
\Magento\Framework\App\Config\ScopeConfigInterface already exists in context object
\Magento\Store\Model\StoreManagerInterface already exists in context object
Total Errors Count: 3
Errors during compilation:
Yireo\GoogleTagManager2\Block\Category
Incorrect dependency in class Yireo\GoogleTagManager2\Block\Category in /Applications/MAMP/htdocs/magento2/app/code/Yireo/GoogleTagManager2/Block/Category.php
\Magento\Framework\App\Config\ScopeConfigInterface already exists in context object
\Magento\Store\Model\StoreManagerInterface already exists in context object
\Magento\Framework\View\LayoutInterface already exists in context object
Yireo\GoogleTagManager2\Block\Generic
Incorrect dependency in class Yireo\GoogleTagManager2\Block\Generic in /Applications/MAMP/htdocs/magento2/app/code/Yireo/GoogleTagManager2/Block/Generic.php
\Magento\Framework\App\Config\ScopeConfigInterface already exists in context object
\Magento\Store\Model\StoreManagerInterface already exists in context object
Yireo\GoogleTagManager2\Block\Order
Incorrect dependency in class Yireo\GoogleTagManager2\Block\Order in /Applications/MAMP/htdocs/magento2/app/code/Yireo/GoogleTagManager2/Block/Order.php
\Magento\Framework\App\Config\ScopeConfigInterface already exists in context object
\Magento\Store\Model\StoreManagerInterface already exists in context object
Total Errors Count: 3

Errors during compilation:
Yireo\GoogleTagManager2\Block\Category
Incorrect dependency in class Yireo\GoogleTagManager2\Block\Category in /Applications/MAMP/htdocs/magento2/app/code/Yireo/GoogleTagManager2/Block/Category.php
\Magento\Framework\App\Config\ScopeConfigInterface already exists in context object
\Magento\Store\Model\StoreManagerInterface already exists in context object
\Magento\Framework\View\LayoutInterface already exists in context object
Yireo\GoogleTagManager2\Block\Generic
Incorrect dependency in class Yireo\GoogleTagManager2\Block\Generic in /Applications/MAMP/htdocs/magento2/app/code/Yireo/GoogleTagManager2/Block/Generic.php
\Magento\Framework\App\Config\ScopeConfigInterface already exists in context object
\Magento\Store\Model\StoreManagerInterface already exists in context object
Yireo\GoogleTagManager2\Block\Order
Incorrect dependency in class Yireo\GoogleTagManager2\Block\Order in /Applications/MAMP/htdocs/magento2/app/code/Yireo/GoogleTagManager2/Block/Order.php
\Magento\Framework\App\Config\ScopeConfigInterface already exists in context object
\Magento\Store\Model\StoreManagerInterface already exists in context object
Total Errors Count: 3

Installation using composer doesn't work due to psr-4 section being removed in composer.json

Hi

We just tried installing the master branch using composer.
But when we try to deploy this to production, we get:

$ bin/magento setup:di:compile
Compilation was started.
Repositories code generation... 1/7 [====>-----------------------]  14% 1 sec 54.0 MiBPHP Fatal error:  Class 'Yireo\GoogleTagManager2\Block\Generic' not found in vendor/yireo/yireo_googletagmanager2/Block/Category.php on line 16

Fatal error: Class 'Yireo\GoogleTagManager2\Block\Generic' not found in vendor/yireo/yireo_googletagmanager2/Block/Category.php on line 16

If we install the module manually in app/code everything works fine. So this must have something to do with the composer-specific installation.

I'm pretty sure the issue has been introduced in 07b07cd#diff-b5d0ee8c97c7abd7e3fa29b9a27d1780

I'm pretty sure the psr-4 section should have remained in there, and should have been changed to:

"psr-4": {
    "Yireo\\GoogleTagManager2\\": ""
},

Thanks for the module btw, nice work! :)

RuntimeException thrown on product view

I get the exception:
Source class "\Yireo\GoogleTagManager2\ViewModel\Product" for "Yireo\GoogleTagManager2\ViewModel\Product\Interceptor" generation does not exist.

When I take a look at the ViewModel directory, the Product file/class is missing indeed.

E-commerce data not tracked in Google Analytics

Hello,

First of all, nice extension ๐Ÿ‘

I have a small problem with it. We had correct e-commerce tracking in Google Analytics for one day, but suddenly it stopped working. We also did an upgrade to version 0.3.16 but still no tracking of e-commerce data in GA. I used both insertion methods observer and xml layout for several days. And also see that the dataLayer variable is filled with transaction information. All the other tracking works fine.

We have e-commerce tracking enabled at the GA settings in Google Tag Manager. And trigger the Google Analytics tag at DOM ready, maybe this is too early? Or do we need a custom trigger / tag for e-commerce tracking (for this extension)?

I use the same Google Tag Manager and Google Analytics setup with DuracellTomi's Google Tag Manager for WordPress for WooCommerce and the e-commerce tracking works fine there.

But maybe it is an event problem or something?

Thanks in advance!

Version 0.3.8

No pressure, but I would really appreciate a new version ๐Ÿ˜

composer.json lacks module version

currently this extension does not define any version information so you could add a

"version": "yourversion",

to composer.json so it can be required by version or compared or made as a dependency in composer.

I can see that setup_version is defined in module.xml file but this is not a version info composer can read (or meant for defining m2 version information as this is a setup version)

Product price for configurable products is 0 on product detail

On product detail pages for configurable products, the value for 'productPrice' will always be 0.
The module is calling the following code in /view/frontend/templates/product.phtml

    <?php $block->addAttribute('productPrice', $product->getPrice()); ?>

The getPrice() function should be the getFinalPrice() function.

Tested with the latest version of this module on a Magento 2.1.11

New version

Would it be possible to release a new version? I'd like to install my changes without the use of dev-master.

Typo in Yireo\GoogleTagManager2\Block\Quote

Line 35 of Yireo\GoogleTagManager2\Block\Quote reads:

'productId' => $item->getProduct->getId(),

This produces a notice as getProduct should have been called as a method

Error

Hi,

i've installed Tag Manager on Magento 2.0.4. and upon enabling it within the administration (observer) it gives the following error:

Fatal error: Uncaught Error: Call to a member function getNameInLayout() on null in /var/www/html/site/app/code/Yireo/GoogleTagManager2/Observer/CoreLayoutRenderElement.php:45 Stack trace: #0 /var/www/html/site/vendor/magento/framework/Event/Invoker/InvokerDefault.php(73): Yireo\GoogleTagManager2\Observer\CoreLayoutRenderElement->execute(Object(Magento\Framework\Event\Observer)) #1 /var/www/html/site/vendor/magento/framework/Event/Invoker/InvokerDefault.php(61): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Yireo\GoogleTagManager2\Observer\CoreLayoutRenderElement), Object(Magento\Framework\Event\Observer)) #2 /var/www/html/site/vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer)) #3 /var/www/html/site/var/generation/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch('core_layout_ren...', Array) #4 /var/www/html/site/vendor/magento/framework/View/Layout.php( in /var/www/html/site/app/code/Yireo/GoogleTagManager2/Observer/CoreLayoutRenderElement.php on line 45

Magento 2.2 compatibility

What would be the minimum effort to make the module Magento 2.2 compatible?

Changing the magento/module-catalog version to 102.0.* in composer.json would be a great start, but I'm not sure if the codebase is compatible with 2.2. Once the module is M2.2 compatible, things like ViewModels can be implemented the way Magento designed it.

Anyone has any ideas? I'm trying to get this going.

(Suggestion) More logical place for module configuration

Not really an issue but more of a request/suggestion;

Currently the configuration settings are placed under Advanced.
For us (and our marketeers) this doesn't really seem like a logical place.

Maybe you could consider moving it to "Marketing" or "Sales > Google API" ?

Product Qty on Success Page

On Magento 2.1.12 with module version 0.3.12, the quantity for any product in transactionProducts is null.

Possible fix in CustomerData/Order.php would be to replace $item->getQty() with $item->getQtyOrdered():

    private function getItemsAsArray()
    {
        $order = $this->order;
        $data = [];

        foreach ($order->getItemsCollection() as $item) {
            /** @var Item $item */
            $data[] = [
                'productId' => $item->getProduct()->getId(),
                'sku' => $item->getProduct()->getSku(),
                'name' => $item->getProduct()->getName(),
                'price' => $item->getProduct()->getPrice(),
                'quantity' => $item->getQty(),
            ];
        }

        return $data;
    }

with

    private function getItemsAsArray()
    {
        $order = $this->order;
        $data = [];

        foreach ($order->getItemsCollection() as $item) {
            /** @var Item $item */
            $data[] = [
                'productId' => $item->getProduct()->getId(),
                'sku' => $item->getProduct()->getSku(),
                'name' => $item->getProduct()->getName(),
                'price' => $item->getProduct()->getPrice(),
                'quantity' => $item->getQtyOrdered(),
            ];
        }

        return $data;
    }

Setup:upgrade results in error Magento\Framework\Locale\Resolver

When I install the latest version of module on my Magento 2.3.1 installation, I get the following error while running a setup:upgrade:
Type Error occurred when creating object: Magento\Framework\Locale\Resolver

When I remove the module, I can run a setup:upgrade again.

Installation problem with magento 2.1

Dears,
first of all thank you for developing this extension.

I am trying to install it in a fresh new installation of magento 2.1 with php7 using MAMP

Unfortunately nothing appear in the configuration.php and the command lines are executed without any feedback (both with and without sudo privileges)

Commands:
sudo php -c /Applications/MAMP/bin/php/php7.0.10/conf/php.ini -f bin/magento module:enable Yireo_GoogleTagManager2
sudo php -c /Applications/MAMP/bin/php/php7.0.10/conf/php.ini -f bin/magento setup:upgrade

Directory where I have the files
/Applications/MAMP/htdocs/magento2/app/code/Yireo/GoogleTagManager2

Do you have any advice?

Huge amount of section requests

Server load seems to be increased in factors since the module is installed. Went through some of the logs, noticing about 3-10% of all traffic are section updates by Yireo GTM2.

I looked into this and noticed that a lot of duplicate data (without changes) are added to the DataLayer by subscribing to cart section updates for refresh.

There might be some improvements that can be made, a lot of data in DataLayer is already available client side in the localStorage (mage-cache-storage -> cart). It seems unnecessary to update currency every time, this can be cached client side.
You might be able to reduce section updates to zero, which increases performances a lot.

Any thoughts on this?

(Using latest version of the module)

Incompatibility with Google Optimize standard implementation

We ran into an issue with the module where tags in GTM were fired, but all the data layer properties were undefined. We traced it to the fact that we had recently installed Google Optimize on the site according to the standard instructions.

What is not obvious from the Google Optimize instructions is that doing so actually triggers the instantiation of GTM. In keeping with the instructions for Optimize, this was added high on the page, in the <head>. This is beneficial for Optimize so that A/B tests can be applied to the page with a minimum of "jerk" where the user sees the non-test version before the test applies.

Unfortunately, because it is in the <head> and because it triggers GTM, it means that the data layer is not loaded by the time the GTM "page load" events fire. When this module is used by itself, the data layer is populated by this time since the module doesn't call GTM until after the global dataLayer variable is setup.

Our solution is to add the following as a theme override of custom.phtml so that the asynchronous data layer push performed by the module has a named event attached. We can then change our GTM tags to trigger on the new datalayer.load event instead.

<?php
/** @var \Yireo\GoogleTagManager2\Block\Category $block */
$helper = $block->getHelper();
?>
<?php if($helper->isEnabled()) : ?>
    <?php $block->addAttribute('event', 'datalayer.load'); ?>
<?php endif; ?>

Is that a solution that you'd want to consider building into the module itself (obviously not through custom.phtml, but in some other spot)? At a minimum it may be worth documenting this potential issue in the README.

Incorrect values on order success page (?)

Hey,

We're having two issues with the transaction values that are added to the dataLayer on the order success page. On this page, we've set a 'Universal Analytics' trigger in our Google Tag Manager with the track type 'Transaction'. Without any further configuration, this trigger successfully sends some variables to analytics. However, there seem to be some inconsistencies between the values of the variables: some are including tax, some are not. The transactionTax variable also seems to have a complete incorrect value.

My first question is: in our previous Magento 1.x setups with another module that generated the dataLayer, the value that was sent to analytics which is shown in the "Revenue" column when viewing conversions, was the revenue on the order excluding tax but also excluding shipping costs, since these are sent to and shown in analytics separately. The transactionTotal variable in this module is the grand total of the order including tax and shipping costs, and this is the value that shows up in our "Revenue" column. I could be wrong, but shouldn't this value be the total revenue on products in the order, excluding shipping, excluding tax? Or is there a way to use the transactionSubtotal variable to fill the "Revenue" column in stead? How should we set up our trigger? Or are we seeing things wrong and is there some documentation or resource that suggests the revenue column should actually include shipping and tax, meaning there's nothing wrong with this module's implementation ๐Ÿ˜?

Second, I believe the transactionTax value is calculated incorrectly. Let's take an example order to illustrate:

1 x Product โ‚ฌ25,50 (incl. 21% TAX)

Subtotal โ‚ฌ25,50 (incl. 21% TAX)
Shipping โ‚ฌ4,95 (incl. 21% TAX)
TAX โ‚ฌ5,28 (โ‚ฌ4,42 product, โ‚ฌ0,86 shipping)

Total โ‚ฌ30,45 (incl. 21% TAX)

The values that are added to the dataLayer for this order are:

transactionTotal: 30.45,  //Order total incl. shipping and tax
transactionSubtotal: 21.07, //Order total excl. shipping and tax
transactionTax: 9.38, //TAX + shipping excl. tax
transactionShipping: 4.1 //Shipping costs excl. tax

In order.phtml the transactionTax value is calculated as follows: $order->getGrandTotal() - $order->getSubtotal());, but what this essentially does is it subtracts the subtotal of the products (21,07) from the grand total of the order, including shipping costs (25,50 + 4,95), leaving us with a value (9,38) that is built up of our TAX (5,28) and the shipping costs excluding TAX (4,10).
Isn't there something like $order->getTaxAmount() that can give us the correct amount without having to calculate it ourselves?

Sorry for the wall of text, hope it's clear enough!
Thanks :)

If logged in customer places 2nd order, transaction info is from the 1st order

On Magento 2.1.12 with module version 0.3.12. After placing an order, if a customer is logged in and goes back and places a second order on the success page the transactionEntity Order information (transactioDate, transactionId, transactionPayment, transactionProducts, transactionShipping, transactionSubtotal, transactionTax, transactionTax) is from the first order.

The transactionEntity Quote in the cart and checkout pulls through the information from the correct quote its just once you get to the success page

Can you host this on the magento store?

HI - Great job in releasing this.
Are you able to host it on the magento store - then its easier to spin up a test instance on Magecloud so I can help you debug the issues.

I do tag manager for a lot of magento sites so having a great open source alternative for Community versions would be epic.
Happy to help make this happen.
Cheers

Section updates in the checkout is through the roof

Every keystroke in the checkout is refreshing the the yireo sections;
This is producing an unresponsive checkout sometimes (because of the number of queued refreshes)

It's this part in view/frontend/web/js/generic.js that's causing the massive requests amount

var monitorCheckout = function () {
    var checkout = customerData.get('checkout-data');
    checkout.subscribe(function (updatedCart) {
        customerData.reload(['yireo-gtm-quote', 'yireo-gtm-order']);
    });
    return true;
};

I think the only thing that we actually need to track during the checkout is if the quote totals get updated which can be done with:


define([
    'jquery',
    'underscore',
    'Magento_Customer/js/customer-data',
    'Magento_Checkout/js/model/quote'
], function ($, _, customerData, quote) {
...
var monitorCheckout = function () {
    quote.totals.subscribe(function (newValue) {
        customerData.reload(['yireo-gtm-quote', 'yireo-gtm-order']);
    });
    return true;
};
...

Order information is missing in the datalayer for cart and checkout page.

The datalayer is send to Google tag manager but the order information is missing:

{
customerLoggedIn: 0,
pageType: 'checkout/onepage/success',
gtm: {start: 1512984061563, uniqueEventId: 3},
event: 'gtm.load'
}

The call to /customer/section/load/?sections=yireo-gtm-quote%2Cyireo-gtm-order&_=1515409543661 returns the correct data, but this data is not added to the dataLayer. We use Magento 2.2.1

[CRITICAL] On pages that have no product/category/order/quote/custom data, the tagmanager is not working correctly

In Yireo\GoogleTagManager2\Helper\Data in function getHeaderScript() the $childScript variable for Yireo\GoogleTagManager2\Block\Generic getJsonConfiguration() is being created.

Yireo\GoogleTagManager2\Helper\Data

public function getHeaderScript()
{
    $childScript = '';

    // Load the main script
    if (!($block = $this->fetchBlock('generic', 'generic', 'generic.phtml'))) {
        return $childScript;
    }

    // Add product-information
    $this->addProduct($childScript);

    // Add category-information
    $this->addCategory($childScript);

    // Add order-information
    $lastOrderId = $this->checkoutSession->getLastRealOrderId();
    if (!empty($lastOrderId)) {
        $this->addOrder($childScript);

        // Add quote-information
    } else {
        $this->addQuote($childScript);
    }

    // Add custom information
    $this->addCustom($childScript);

    $block->setChildScript($childScript);
    $html = $block->toHtml();

    return $html;
}

Yireo\GoogleTagManager2\Block\Generic

public function getJsonConfiguration()
{
    $configuration = [];
    if (empty($this->getChildScript())) {
        return $this->jsonEncoder->encode($configuration);
    }

    $configuration['attributes'] = $this->getAttributes();
    $configuration['id'] = $this->getId();

    return $this->jsonEncoder->encode($configuration);
}

However, on pages that have no product/category/order/quote/custom data the $childScript will be empty which causes the tagmanager to be loaded with id 'undefined'

It is my opinion that the empty check in getJsonConfiguration() should be dropped entirely.

public function getJsonConfiguration()
{
    $configuration = [];

    $configuration['attributes'] = $this->getAttributes();
    $configuration['id'] = $this->getId();

    return $this->jsonEncoder->encode($configuration);
}

Unit tests are based on a non-composer module installation

As you recommend users to install the module using composer, it would be nice to be able to test it from the vendor directory as well.

I installed the module using composer, but I had to tweak the phpunit.yireo.xml to get the tests running.

[Critical] Customer related data is incorrect due to cache

The customer information sent to the dataLayer can be incorrect if the page has been cached by FPC already.

Prereq:

  • Tested on Magento2 CE 2.1.5, 2.1.6, 2.1.7
  • PHP 7.0

Steps to reproduce:

  • Make sure the FPC is enabled (which should be the case for every webshop in production!)
  • Go to a page on the webshop and look at the data sent to the layer (customerId will be 0)
  • Log in
  • Go to the same page as step 2 and look at the data sent to the layer (customerId is still 0)

Everything that is dynamic should not be put into a static block.
The 'easy' way out would be to make the 'googletagmanager_script' block not cacheable but this will cause every page not being able to be cached (never ever do this!). The good way to do this would be to use customerData sections in which the dynamic information is being sent to the dataLayer

Not showing in admin

I installed with composer but its not showing in Admin. My Magento version is 2.1.2 ...
Please suggest

Division by zero issue when showing all products per page

When showing all items per page (option disabled by default), category pages throw a division by zero fatal error. This is generated in Yireo\GoogleTagManager2\Block\Category:

$collection->setCurPage($this->getCurrentPage())->setPageSize($this->getLimit());

Limit is set to zero in this case.

Error getting store name

Notice: Undefined property: Yireo\GoogleTagManager2\Block\Quote::$scopeConfig in /Yireo/GoogleTagManager2/Block/Generic.php on line 179 [] []

Might be related to this?
Broken reference: No element found with ID 'checkout.header.wrapper'. [] []

Config location

Does the configuration for this module have to be under the "Sales" section? It doesn't relate to sales, and Tag Manager can be used for anything. It would make more sense to be located under "Services".

Cannot find module config m2 2.3.3

Hello, after enabling the module and recompiling the whole m2 and logging of the admin and on and of course checking if module is enabled in the setup i cannot find the module configuration :S

i go to Stores -> (settings) configration-> Sales tab and there is nothing there :(
Any thoughts please?

2019-12-10_10-23-09_explorer

Best regards,
Alexander

Category position problem

After installing, product position and sort by functionality on category and search view stopped working. We are using Magento 2.1.3

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.