Skip to content

Commit

Permalink
Merge pull request #5 from tagconcierge/develop
Browse files Browse the repository at this point in the history
1.0.2
  • Loading branch information
mfrankiewicz authored Jun 2, 2023
2 parents 606366d + 94417b5 commit ce2c935
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 13 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Change Log
All notable changes to this project will be documented in this file.

## [1.0.2] - 2023-06-02

### Added
- support for Przelewy24 payment module

### Changed

### Fixed

## [1.0.1] - 2023-04-19
GTM body snippet should be provided again in module configuration after upgrade.

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
2023 Handcraft Byte
2023 Tag Concierge

NOTICE OF LICENSE

Expand Down
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,44 @@
# Tag Concierge PrestaShop Module Free
This extension pushes standard eCommerce information – **GA4 Commerce and UA Enhanced eCommerce compatible** – to GTM Data Layer. Once this information is available in your GTM workspace you can plug in and use any tool available, even if you are unsure which tool you need or would like to use.

![image](https://user-images.githubusercontent.com/18583662/232718044-5496a26e-553c-4231-bba8-ddbec06e0c55.png)
<p align="center">
<img src="https://user-images.githubusercontent.com/18583662/232718044-5496a26e-553c-4231-bba8-ddbec06e0c55.png" />
</p>

GTM setup can be cumbersome and time-consuming – this extension comes with packaged presets for 4 main tools in the market that allow you to set up and run the integration in few simple steps without creating every single GTM Variable and Trigger yourself.

![gif](https://user-images.githubusercontent.com/18583662/232718426-4fec6b72-7bba-4b48-be29-00a438385847.gif)
<p align="center">
<img src="https://user-images.githubusercontent.com/18583662/232718426-4fec6b72-7bba-4b48-be29-00a438385847.gif" />
</p>

Tag Concierge integrates your PrestaShop shop with a GTM container. It can work with existing GTM installation and allows injecting the GTM snippets in the settings.

![image](https://user-images.githubusercontent.com/18583662/232718949-ea27f1d3-06d0-45e6-9d2e-b10e6df2c78d.png)
<p align="center">
<img src="https://user-images.githubusercontent.com/18583662/232718949-ea27f1d3-06d0-45e6-9d2e-b10e6df2c78d.png" />
</p>

The extension starts to work without any additional installation. Once it is activated and GTM is embedded in the website, it starts to emit eCommerce events to the GTM dataLayer. Those events are compatible with the newest GA4 format but can be adapted to different tools, including UA and Facebook Pixel.

![image](https://user-images.githubusercontent.com/18583662/232719076-bb557af4-abae-4e30-a3e2-220a48f96c8e.png)
<p align="center">
<img src="https://user-images.githubusercontent.com/18583662/232719076-bb557af4-abae-4e30-a3e2-220a48f96c8e.png" />
</p>

![image](https://user-images.githubusercontent.com/18583662/232719118-9a17b117-3de5-49a3-8834-f5bad1fe2d3d.png)
<p align="center">
<img src="https://user-images.githubusercontent.com/18583662/232719118-9a17b117-3de5-49a3-8834-f5bad1fe2d3d.png" />
</p>

From there, virtually any integration can be achieved through GTM and the same data from your shop can be sent out to any analytical or optimization tool.
But to make it easier, the extension comes with **packaged GTM presets** that can be imported into GTM workspace to enable dataflow to specific tool in few simple steps without creating every single GTM Tag, Variable, and Trigger manually.

![image](https://user-images.githubusercontent.com/18583662/232719541-3ca2bb80-dbd9-4773-a215-81a046c48a7d.png)
<p align="center">
<img src="https://user-images.githubusercontent.com/18583662/232719541-3ca2bb80-dbd9-4773-a215-81a046c48a7d.png" />
</p>

That’s it. With the help of the extension and packaged presets, you can start analyzing and optimizing your PrestaShop shop in almost no time.

![image](https://user-images.githubusercontent.com/18583662/232719590-bd041a18-cfcc-44a3-88a1-0911314f7911.png)
<p align="center">
<img src="https://user-images.githubusercontent.com/18583662/232719590-bd041a18-cfcc-44a3-88a1-0911314f7911.png" />
</p>

See [**our documentation**](https://tagconcierge.com/tag-concierge-for-prestashop) for the list of all supported events.

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function postProcess()

ob_end_clean();
header('Content-Type: application/json');
$this->ajaxDie(json_encode($response, JSON_THROW_ON_ERROR, 512));
$this->ajaxDie(json_encode($response));
}

private function getCart(): array
Expand Down
46 changes: 44 additions & 2 deletions src/Hook/Event/Browser/PurchaseHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,62 @@ class PurchaseHook extends AbstractHook
Hooks::DISPLAY_ORDER_CONFIRMATION => [
'addDataElementInOrderConfirmationPage',
],
Hooks::DISPLAY_AFTER_BODY_OPENING_TAG => [
'p24Compatibility',
],
];

public function addDataElementInOrderConfirmationPage(array $data): string
{
if (true === $this->isP24ConfirmationPage()) {
return '';
}

/** @var PrestaShopOrder $orderObject */
$orderObject = $data['order'];

$order = Order::fromOrderObject($orderObject);
return $this->handlePurchaseEvent($orderObject);
}

public function p24Compatibility(array $data): string
{
if (false === $this->isP24ConfirmationPage()) {
return '';
}

$orderId = PrestaShopOrder::getIdByCartId($this->getContext()->cart->id);

if (false === $orderId) {
return '';
}

$order = new PrestaShopOrder($orderId);

return $this->handlePurchaseEvent($order);
}

private function handlePurchaseEvent(PrestaShopOrder $order): string
{
$orderModel = Order::fromOrderObject($order);

$this->getContext()->smarty->assign('tc_order', $order->toArray());
$this->getContext()->smarty->assign('tc_order', $orderModel->toArray());

return $this->module->display(
\TagConciergeFree::MODULE_FILE,
'views/templates/hooks/purchase/display_order_confirmation.tpl'
);
}

private function isP24ConfirmationPage(): bool
{
$controller = $this->getContext()->controller;

if (null === $controller) {
return false;
}

$controllerClass = get_class($controller);

return 'przelewy24paymentconfirmationmodulefrontcontroller' === strtolower($controllerClass);
}
}
2 changes: 1 addition & 1 deletion tagconciergefree.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct()
{
$this->name = 'tagconciergefree';
$this->author = 'Tag Concierge';
$this->version = '1.0.1';
$this->version = '1.0.2';
$this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_];
$this->bootstrap = true;
$this->tab = 'advertising_marketing';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
if (null === tagConcierge.lastPrestashopCartFromResponse) {
jQuery.ajax({
type: 'POST',
url: '/index.php?fc=module&module=tag_concierge&controller=ajax&ajax=true',
url: '/index.php?fc=module&module=tagconciergefree&controller=ajax&ajax=true',
data: 'action=getCart',
async: false,
success: function (d) {
Expand Down

0 comments on commit ce2c935

Please sign in to comment.