Skip to content

Commit a5a742b

Browse files
FFWEB-2645: new cart tracking
1 parent 01129aa commit a5a742b

10 files changed

Lines changed: 181 additions & 125 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# Changelog
2+
## Unreleased
3+
### Add
4+
- Tracking
5+
- Add option to select scenario when `Add To Cart button` has been clicked
6+
27
## [v4.3.7] - 2022.01.24
38
### Fix
49
- Fix add to cart tracking for configurable products

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ You can find more information about mentioned properties purposes in Web Compone
117117
* `Anonymize User ID?` - check this option if you want to send user id with tracking requests in anonymized form. By default the regular id field from user table is sent.
118118
* `Use Proxy` - check this option if you want each request sends by Web Components first reach the dedicated module controller which forwards it to the FACT-Finder.
119119
**Note:** If you plan to use proxy, consider reading below paragraph as it requires full instruction how to enable it properly.
120-
120+
* `How to count single click on "Add to cart" button?` - select how would you like to count single click on "Add to cart" button
121+
121122
#### Proxy
122123
Proxy feature adds a oxid controller which serves as a middleware between Web Components and FACT-Finder®.
123124
The data flow with proxy enabled is illustrated by the graph below.

docs/assets/advanced-settings.png

2.09 KB
Loading

src/Component/Widget/WebComponent.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ public function getSearchImmediate(): bool
3131
{
3232
return $this->config->getParameters()['search-immediate'] === 'true';
3333
}
34+
35+
public function getTrackingSettings(): array
36+
{
37+
return $this->config->getTrackingSettings();
38+
}
3439
}

src/Model/Config/Communication.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ public function getParameters(): array
5757
return array_filter($this->mergeParameters($params, $this->getAdditionalParameters()));
5858
}
5959

60+
public function getTrackingSettings(): array
61+
{
62+
return [
63+
'addToCart' => [
64+
'count' => $this->getConfig('ffTrackingAddToCartCount') ?? 'count_as_one',
65+
],
66+
];
67+
}
68+
6069
protected function getUserId(): string
6170
{
6271
$session = Registry::getSession();

src/metadata.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@
212212
'value' => false,
213213
'position' => $settingPosition++,
214214
],
215+
[
216+
'group' => 'ffAdvanced',
217+
'name' => 'ffTrackingAddToCartCount',
218+
'type' => 'select',
219+
'value' => 'count_as_one',
220+
'constraints' => 'count_as_one|count_selected_amount',
221+
'position' => $settingPosition++,
222+
],
215223
[
216224
'group' => 'ffFeatures',
217225
'name' => 'ffUseForCategories',

src/out/js/tracking.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,34 @@ function registerAddToCartListener(selector, productData) {
99

1010
function init(selector, productData) {
1111
const trackingHelper = factfinder.communication.Util.trackingHelper;
12+
const element = document.querySelector(selector);
13+
const amountInput = element.querySelector('#amountToBasket');
14+
15+
function getQuantity()
16+
{
17+
if (ffTrackingSettings.addToCart.count === 'count_as_one') {
18+
return 1;
19+
}
20+
21+
if (!amountInput) {
22+
return 1;
23+
}
24+
25+
return parseInt(amountInput.value);
26+
}
1227

1328
function trackAddToCart(product) {
29+
const quantity = getQuantity();
30+
1431
factfinder.communication.Tracking.cart({
1532
id: trackingHelper.getTrackingProductId(product),
1633
masterId: trackingHelper.getMasterArticleNumber(product),
1734
price: trackingHelper.getPrice(product),
1835
title: trackingHelper.getTitle(product),
19-
count: 1,
36+
count: quantity,
2037
});
2138
}
2239

23-
const element = document.querySelector(selector);
2440

2541
if (element) {
2642
element.addEventListener('submit', function (e) {

src/views/admin/de/ffwebcomponents_lang.php

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,68 @@
33
$sLangName = 'Deutsch';
44

55
$aLang = [
6-
'charset' => 'UTF-8',
7-
'SHOP_MODULE_GROUP_ffMain' => 'Grundeinstellungen',
8-
'SHOP_MODULE_ffServerUrl' => 'Server-URL',
9-
'SHOP_MODULE_ffChannel' => 'Channel',
10-
'SHOP_MODULE_ffUsername' => 'Benutzername für den FACT-Finder Import User',
11-
'SHOP_MODULE_ffPassword' => 'Passwort',
12-
'SHOP_MODULE_ffAuthPrefix' => 'Authorisierungs-Präfix',
13-
'SHOP_MODULE_ffAuthPostfix' => 'Authorisierungs-Postfix',
14-
'SHOP_MODULE_GROUP_ffAdvanced' => 'Erweiterte Einstellungen',
15-
'SHOP_MODULE_ffVersion' => 'Version',
16-
'SHOP_MODULE_ffVersion_6.9' => '6.9',
17-
'SHOP_MODULE_ffVersion_6.10' => '6.10',
18-
'SHOP_MODULE_ffVersion_6.11' => '6.11',
19-
'SHOP_MODULE_ffVersion_7.0' => '7.0',
20-
'SHOP_MODULE_ffVersion_7.1' => '7.1',
21-
'SHOP_MODULE_ffVersion_7.2' => '7.2',
22-
'SHOP_MODULE_ffVersion_7.3' => '7.3',
23-
'SHOP_MODULE_ffVersion_ng' => 'NG',
24-
'SHOP_MODULE_ffApiVersion' => 'Api Version',
25-
'SHOP_MODULE_ffApiVersion_v4' => 'v4',
26-
'SHOP_MODULE_ffApiVersion_v5' => 'v5',
27-
'SHOP_MODULE_ffUseUrlParams' => 'URL-Parameter benutzen?',
28-
'SHOP_MODULE_ffAnonymizeUserId' => 'Anonymize User ID?',
29-
'SHOP_MODULE_ffUseProxy' => 'Proxy benutzen?',
30-
'SHOP_MODULE_ffAddSearchParams' => 'Zusätzliche Parameter',
31-
'HELP_SHOP_MODULE_ffAddSearchParams' => 'Es gibt vier Parameter, die Sie einstellen können:`add-params`, `add-tracking-params`, `keep-url-params`, `parameter-whitelist`. Jede Parameterdefinition sollte in einer separaten Zeile stehen. Beispiel-Verwendung: add-params => customParam1 => value1, customParam2 => value2',
32-
'SHOP_MODULE_GROUP_ffFeatures' => 'Features Settings',
33-
'SHOP_MODULE_ffUseForCategories' => 'Kategorieseiten mit FACT-Finder® rendern?',
34-
'SHOP_MODULE_ffCampaigns' => 'Kampagnen',
35-
'SHOP_MODULE_ffRecommendations' => 'Empfehlungen',
36-
'SHOP_MODULE_ffSimilarProducts' => 'Ähnliche Produkte',
37-
'SHOP_MODULE_ffPushedProducts' => 'Pushed products',
38-
'SHOP_MODULE_GROUP_ffFeed' => 'Feed-Einstellungen',
39-
'SHOP_MODULE_ffExportAttributes' => 'Exportierte Attribute',
40-
'HELP_SHOP_MODULE_ffExportAttributes' => 'Wähle die Attribute aus, die du exportieren möchtest. Multi-Attribute werden in einer Spalte gruppiert, und stellen typischerweise Filter dar.',
41-
'SHOP_MODULE_GROUP_ffExport' => 'Export-Einstellungen',
42-
'SHOP_MODULE_ffFtpType' => 'Protocol',
43-
'SHOP_MODULE_ffFtpType_ftp' => 'FTP',
44-
'SHOP_MODULE_ffFtpType_sftp' => 'SFTP',
45-
'SHOP_MODULE_ffFtpHost' => 'Host',
46-
'SHOP_MODULE_ffFtpPort' => 'Port',
47-
'SHOP_MODULE_ffFtpUser' => 'User',
48-
'SHOP_MODULE_ffFtpPassword' => 'Password',
49-
'SHOP_MODULE_ffFtpKey' => 'Key',
50-
'SHOP_MODULE_ffFtpKeyPassphrase' => 'Key Passphrase',
51-
'SHOP_MODULE_ffFtpRoot' => 'Server Root',
52-
'SHOP_MODULE_ffSSLEnabled' => 'SSL aktiv?',
53-
'SHOP_MODULE_ffAutomaticImport' => 'Automatic import of product',
54-
'SHOP_MODULE_ffAutomaticImportData' => 'Import Data',
55-
'SHOP_MODULE_ffAutomaticImportSuggest' => 'Import Suggest',
56-
'SHOP_MODULE_ffAutomaticImportRecommendation' => 'Import Recommendation',
57-
'SHOP_MODULE_ffHTTPExportUser' => 'Basic Auth user for HTTP export',
58-
'SHOP_MODULE_ffHTTPExportPassword' => 'Basic Auth password for HTTP export',
59-
'SHOP_MODULE_ffLogPath' => 'Log path',
60-
'SHOP_MODULE_ffIsProceedWhileError' => 'Proceed with export when error occurred',
61-
'HELP_SHOP_MODULE_ffPushedImportTypes' => 'Verfügbare Werte: data, suggest',
62-
'SHOP_MODULE_ffFieldRoles' => 'Update Field Roles',
63-
'FF_TEST_CONNECTION_SUCCESS' => 'Connection has been established successfully',
64-
'FF_ARTICLE_FEED_EXPORT_SUCCESS' => 'Article Feed has been exported succesfully',
65-
'FF_ARTICLE_FEED_UPLOAD_SUCCESS' => 'Article Feed has been uploaded succesfully',
66-
'FF_ARTICLE_FEED_IMPORT_TRIGGERED' => 'Import feed file has been triggered',
6+
'charset' => 'UTF-8',
7+
'SHOP_MODULE_GROUP_ffMain' => 'Grundeinstellungen',
8+
'SHOP_MODULE_ffServerUrl' => 'Server-URL',
9+
'SHOP_MODULE_ffChannel' => 'Channel',
10+
'SHOP_MODULE_ffUsername' => 'Benutzername für den FACT-Finder Import User',
11+
'SHOP_MODULE_ffPassword' => 'Passwort',
12+
'SHOP_MODULE_ffAuthPrefix' => 'Authorisierungs-Präfix',
13+
'SHOP_MODULE_ffAuthPostfix' => 'Authorisierungs-Postfix',
14+
'SHOP_MODULE_GROUP_ffAdvanced' => 'Erweiterte Einstellungen',
15+
'SHOP_MODULE_ffVersion' => 'Version',
16+
'SHOP_MODULE_ffVersion_6.9' => '6.9',
17+
'SHOP_MODULE_ffVersion_6.10' => '6.10',
18+
'SHOP_MODULE_ffVersion_6.11' => '6.11',
19+
'SHOP_MODULE_ffVersion_7.0' => '7.0',
20+
'SHOP_MODULE_ffVersion_7.1' => '7.1',
21+
'SHOP_MODULE_ffVersion_7.2' => '7.2',
22+
'SHOP_MODULE_ffVersion_7.3' => '7.3',
23+
'SHOP_MODULE_ffVersion_ng' => 'NG',
24+
'SHOP_MODULE_ffApiVersion' => 'Api Version',
25+
'SHOP_MODULE_ffApiVersion_v4' => 'v4',
26+
'SHOP_MODULE_ffApiVersion_v5' => 'v5',
27+
'SHOP_MODULE_ffUseUrlParams' => 'URL-Parameter benutzen?',
28+
'SHOP_MODULE_ffAnonymizeUserId' => 'Anonymize User ID?',
29+
'SHOP_MODULE_ffTrackingAddToCartCount' => 'How to count single click on "Add to cart" button?',
30+
'SHOP_MODULE_ffTrackingAddToCartCount_count_as_one' => 'track single click as one',
31+
'SHOP_MODULE_ffTrackingAddToCartCount_count_selected_amount' => 'track single click with selected amount',
32+
'SHOP_MODULE_ffUseProxy' => 'Proxy benutzen?',
33+
'SHOP_MODULE_ffAddSearchParams' => 'Zusätzliche Parameter',
34+
'HELP_SHOP_MODULE_ffAddSearchParams' => 'Es gibt vier Parameter, die Sie einstellen können:`add-params`, `add-tracking-params`, `keep-url-params`, `parameter-whitelist`. Jede Parameterdefinition sollte in einer separaten Zeile stehen. Beispiel-Verwendung: add-params => customParam1 => value1, customParam2 => value2',
35+
'SHOP_MODULE_GROUP_ffFeatures' => 'Features Settings',
36+
'SHOP_MODULE_ffUseForCategories' => 'Kategorieseiten mit FACT-Finder® rendern?',
37+
'SHOP_MODULE_ffCampaigns' => 'Kampagnen',
38+
'SHOP_MODULE_ffRecommendations' => 'Empfehlungen',
39+
'SHOP_MODULE_ffSimilarProducts' => 'Ähnliche Produkte',
40+
'SHOP_MODULE_ffPushedProducts' => 'Pushed products',
41+
'SHOP_MODULE_GROUP_ffFeed' => 'Feed-Einstellungen',
42+
'SHOP_MODULE_ffExportAttributes' => 'Exportierte Attribute',
43+
'HELP_SHOP_MODULE_ffExportAttributes' => 'Wähle die Attribute aus, die du exportieren möchtest. Multi-Attribute werden in einer Spalte gruppiert, und stellen typischerweise Filter dar.',
44+
'SHOP_MODULE_GROUP_ffExport' => 'Export-Einstellungen',
45+
'SHOP_MODULE_ffFtpType' => 'Protocol',
46+
'SHOP_MODULE_ffFtpType_ftp' => 'FTP',
47+
'SHOP_MODULE_ffFtpType_sftp' => 'SFTP',
48+
'SHOP_MODULE_ffFtpHost' => 'Host',
49+
'SHOP_MODULE_ffFtpPort' => 'Port',
50+
'SHOP_MODULE_ffFtpUser' => 'User',
51+
'SHOP_MODULE_ffFtpPassword' => 'Password',
52+
'SHOP_MODULE_ffFtpKey' => 'Key',
53+
'SHOP_MODULE_ffFtpKeyPassphrase' => 'Key Passphrase',
54+
'SHOP_MODULE_ffFtpRoot' => 'Server Root',
55+
'SHOP_MODULE_ffSSLEnabled' => 'SSL aktiv?',
56+
'SHOP_MODULE_ffAutomaticImport' => 'Automatic import of product',
57+
'SHOP_MODULE_ffAutomaticImportData' => 'Import Data',
58+
'SHOP_MODULE_ffAutomaticImportSuggest' => 'Import Suggest',
59+
'SHOP_MODULE_ffAutomaticImportRecommendation' => 'Import Recommendation',
60+
'SHOP_MODULE_ffHTTPExportUser' => 'Basic Auth user for HTTP export',
61+
'SHOP_MODULE_ffHTTPExportPassword' => 'Basic Auth password for HTTP export',
62+
'SHOP_MODULE_ffLogPath' => 'Log path',
63+
'SHOP_MODULE_ffIsProceedWhileError' => 'Proceed with export when error occurred',
64+
'HELP_SHOP_MODULE_ffPushedImportTypes' => 'Verfügbare Werte: data, suggest',
65+
'SHOP_MODULE_ffFieldRoles' => 'Update Field Roles',
66+
'FF_TEST_CONNECTION_SUCCESS' => 'Connection has been established successfully',
67+
'FF_ARTICLE_FEED_EXPORT_SUCCESS' => 'Article Feed has been exported succesfully',
68+
'FF_ARTICLE_FEED_UPLOAD_SUCCESS' => 'Article Feed has been uploaded succesfully',
69+
'FF_ARTICLE_FEED_IMPORT_TRIGGERED' => 'Import feed file has been triggered',
6770
];

0 commit comments

Comments
 (0)