PHP code example of dmitrykazak / magento-google-tag-manager
1. Go to this page and download the library: Download dmitrykazak/magento-google-tag-manager library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dmitrykazak / magento-google-tag-manager example snippets
declare(strict_types=1);
namespace DK\GoogleTagManager\Model\DataLayer\DataProvider;
class CategoryId implements DataProviderInterface
{
public function getData(array $params = []): array
{
return [
'categoryId' => 1,
];
}
}
xml
<type name="DK\GoogleTagManager\Model\DataLayer\DataProvider\DataProviderList">
<arguments>
<argument name="dataProviders" xsi:type="array">
<item name="DK\GoogleTagManager\Model\DataLayer\Dto\Product" xsi:type="array">
<item name="category-id" xsi:type="object">DK\GoogleTagManager\Model\DataLayer\DataProvider\CategoryId</item>
</item>
</argument>
</arguments>
</type>