Skip to content

Commit 4071fc9

Browse files
committed
Merge branch 'master' of github.com:yireo/Yireo_GoogleTagManager2
2 parents 8001459 + 7d45242 commit 4071fc9

File tree

8 files changed

+25
-8
lines changed

8 files changed

+25
-8
lines changed

.module.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ EXTENSION_VENDOR="Yireo"
22
EXTENSION_NAME="GoogleTagManager2"
33
COMPOSER_NAME="yireo/magento2-googletagmanager2"
44
PHP_VERSIONS=("7.4", "8.1", "8.2", "8.3")
5+
PHPSTAN_LEVEL=2

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9-
## [3.9.16] - 17 March 2025
9+
## [3.9.17] - 17 March 2025
1010
### Fixed
1111
- Issue with js minify, script not loaded #269 @taoufiqaitali
12+
- Fix type error when event name is empty #259
13+
14+
## [3.9.16] - 19 February 2025
15+
### Fixed
16+
- Make sure to apply Container URL to IFRAME URL as well #267 @rikwillems
1217

1318
## [3.9.15] - 6 January 2025
1419
### Fixed

DataLayer/Mapper/ProductDataMapper.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ public function mapByProduct(ProductInterface $product): array
8383
}
8484

8585
$productData['price'] = $this->priceFormatter->format((float) $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue());
86-
if ($product->getCustomOption('simple_product') && $product->getCustomOption('simple_product')->getProduct()) {
87-
$simpleProduct = $product->getCustomOption('simple_product')->getProduct();
86+
87+
$simpleProductOption = $product->getCustomOption('simple_product');
88+
if ($simpleProductOption && method_exists($simpleProductOption, 'getProduct') && $simpleProductOption->getProduct()) {
89+
$simpleProduct = $simpleProductOption->getProduct();
8890
$productData['price'] = $this->priceFormatter->format((float) $simpleProduct->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue());
8991
}
9092

FAQ.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ First of all, make sure to upgrade to the latest version of this extension, befo
88

99
When making use of Server-Side Tracking, make sure to customize the setting **Orders states for purchase event** (`order_states_for_purchase_event`) and to manually trigger the `purchase` event where needed.
1010

11+
# The purchase event is fired when the order hasn't been completed yet
12+
The Yireo GoogleTagManager extension uses the core event `sales_order_place_after` to trigger the `purchase` event. And this event is passed on from the server-side (PHP) towards the client-side (JavaScript) whenever a page is hit again (for instance, the loading of the checkout success page) or whenever an AJAX call occurs. At this moment, it might be that the payment has not yet occurred, so that the order status is not yet complete, but still the `purchase` event is triggered. This is **not** a bug, this is where you step in as an integrator of this Yireo GoogleTagManager2 extension and your custom choice of PSPs.
13+
14+
How do you want this to work? Firing the `purchase` event on the success page will often **not** work either: It could be that a payment is delayed, so that the PSP only notifies the Magento application of the payment (so that the order can be completed) *after* the customer has left the shop. A similar scenario pops up when you are placing an order in the Magento Admin Panel. In these scenarios, there no longer is a scenario where client-side tracking (via JavaScript in the frontend) can be used. Instead, the solution is server-side tracking.
15+
16+
The Yireo GoogleTagManager2 extension does not offer server-side tracking as a functionality, but it does support it. Simply enable the setting **Server-Side Tracking**, configure the **Container URL** and select which order states should trigger the `purchase` event (most likely only the `complete` status).
17+
18+
If you need any additional help, the company of [Yireo](https://www.yireo.com/) is happy to help out with a custom (paid) consult as well.
19+
1120
# Does this extension work under PHP 8.2?
1221
Yes, version 3 does. Version 2 is no longer maintained, but you could use the following composer patch with `vaimo/composer-patches`:
1322
```bash

Test/Integration/DataLayer/Event/ViewCartTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testValidViewCartEvent()
3838
$checkoutSession = ObjectManager::getInstance()->get(Session::class);
3939
$checkoutSession->setQuoteId($cartId);
4040
$checkoutSession->getQuote()->collectTotals();
41-
$checkoutSession->getQuote()->save();
41+
$quoteRepository->save($checkoutSession->getQuote());
4242

4343
$cartRepository = ObjectManager::getInstance()->get(CartRepositoryInterface::class);
4444
$cart = $cartRepository->get($cartId);

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "yireo/magento2-googletagmanager2",
3-
"version": "3.9.16",
3+
"version": "3.9.17",
44
"license": "OSL-3.0",
55
"type": "magento2-module",
66
"homepage": "https://www.yireo.com/software/magento-extensions/googletagmanager2",

view/frontend/templates/iframe.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ use Yireo\GoogleTagManager2\Config\Config;
77
/** @var Template $block */
88
$config = $block->getConfig();
99
?>
10-
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=<?= $config->getId() ?>" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
10+
<noscript><iframe src="<?= $config->getGoogleTagmanagerUrl() ?>/ns.html?id=<?= $config->getId() ?>" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>

view/frontend/templates/script.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ $events = ($config->waitForUserInteraction() === false)
3434
f.parentNode.insertBefore(j, f);
3535
})(window, document, 'script', 'dataLayer', '<?= $gtmId ?>');
3636
<?php endforeach; ?>
37-
}
37+
};
3838

3939
events.forEach(function (eventType) {
4040
window.addEventListener(eventType, initYireoGoogleTagManager2, {once: true, passive: true})
41-
})
41+
});
4242
})([<?= $events ?>]);
4343

4444
<?php if ($config->isDebug()): ?>

0 commit comments

Comments
 (0)