- Installation and configuration
- Usage
- Serverside
- Features
- Contribute
- Versioning
- Additional information
composer require buckaroo/magento2analytics
php bin/magento module:enable Buckaroo_Magento2Analytics
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
GA Tracking does not allocate properly the conversion source when the transaction happens cross-browser or cross-device. Visitor lands on the website from an ad campaign, goes through the order process, but the payment process takes place on a different device or browser and success page is also displayed in a different device In order to handle this situation, we track the Google Client ID against the order and we can trigger an enriched version of the tracking code in the success page, by adding the clientId parameter.
clientId
value is passed as a parameter in the URL of the success page, part of the redirect process. This can be extracted and used in the javascript code that triggers the GA/UA/GTM/other event for the conversion.
Standard structure of the URL is the following:
/checkout/onepage/success/?clientId=****/
and the clientId can be extracted:
try{
currentPageUrl = window.location.href;
myClientId = currentPageUrl.split('clientId=')[1].split('/')[0];
} catch(error) {
myClientId = '';
}
and sent to GA/UA part of the tracking code:
ga('create', 'UA-XXXXX-Y', {
'storage': 'none',
'clientId': myClientId
});
The information related to clientId is also stored in the database. And this can be used on the server side level, via the Model repository Buckaroo\Magento2Analytics\Model\AnalyticsRepository
using the quoteId
:
use Buckaroo\Magento2Analytics\Model\AnalyticsRepository;
use Magento\Framework\Exception\NoSuchEntityException;
class MyCustomViewModel
{
public function __construct(
AnalyticsRepository $analyticsRepo
) {
$this->analyticsRepo = $analyticsRepo;
}
public function getClientId($quoteId)
{
$clientId = null;
try {
$clientIdData = $analyticsRepo->getByQuoteId($quote->getId());
return $clientIdData->getClientId();
} catch(\Exception $e) {
throw new NoSuchEntityException(__('ClientId not found for quoteId' . $quoteId ));
}
}
}
• This new feature enables you to add unlimited URL parameters on the success page, utilizing information stored in cookies. This is a significant addition that enables more granular tracking of customer activity and success page interactions, leading to more precise and actionable analytics data.
• The new module is designed for easy use: simply add another pair of cookie name, URL parameter, and the replace regex if you want to extract only a portion of the text. This flexibility allows for precise control over what information is captured and used in your URL parameters.
How to Use:
To utilize this feature:
1. Go to the Buckaroo Magento2_Analytics module settings (Stores → Settings → Configuration → Sales → Buckaroo → GA Tracking Options).
2. Enable GA Tracking.
3. Add a new pair consisting of the cookie name and the URL parameter that you wish to set based on the cookie's value.
4. (Optional) If you only need to extract a specific part of the text, provide a replace regex.
5. Save the settings.
6. The module will automatically handle the rest, setting the URL parameters on your success page based on the specified cookies.
We really appreciate it when developers contribute to improve the Buckaroo plugins. If you want to contribute as well, then please follow our Contribution Guidelines.
- MAJOR: Breaking changes that require additional testing/caution.
- MINOR: Changes that should not have a big impact.
- PATCHES: Bug and hotfixes only.
- Support: https://support.buckaroo.eu/contact
- Contact: [email protected] or +31 (0)30 711 50 50
Please note:
This file has been prepared with the greatest possible care and is subject to language and/or spelling errors.