Skip to content

Commit 69eb439

Browse files
authored
Add insights parameters when click analytics is enabled (#978)
1 parent 56ac3fc commit 69eb439

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

Block/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ public function getConfiguration()
203203
'logo' => $this->getViewFileUrl('Algolia_AlgoliaSearch::images/search-by-algolia.svg'),
204204
],
205205
'ccAnalytics' => [
206+
'enabled' => $config->isClickConversionAnalyticsEnabled(),
206207
'ISSelector' => $config->getClickConversionAnalyticsISSelector(),
207208
'conversionAnalyticsMode' => $config->getConversionAnalyticsMode(),
208209
'addToCartSelector' => $config->getConversionAnalyticsAddToCartSelector(),

view/frontend/web/internals/common.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,20 @@ requirejs(['algoliaBundle'], function(algoliaBundle) {
176176
};
177177

178178
if (hit.__queryID) {
179-
var insightsDataUrlString = $.param({
180-
queryID: hit.__queryID,
181-
objectID: hit.objectID,
182-
indexName: hit.__indexName
183-
});
184-
if (hit.url.indexOf('?') > -1) {
185-
hit.urlForInsights = hit.url + insightsDataUrlString
186-
} else {
187-
hit.urlForInsights = hit.url + '?' + insightsDataUrlString;
179+
180+
hit.urlForInsights = hit.url;
181+
182+
if (algoliaConfig.ccAnalytics.enabled) {
183+
var insightsDataUrlString = $.param({
184+
queryID: hit.__queryID,
185+
objectID: hit.objectID,
186+
indexName: hit.__indexName
187+
});
188+
if (hit.url.indexOf('?') > -1) {
189+
hit.urlForInsights += insightsDataUrlString
190+
} else {
191+
hit.urlForInsights += '?' + insightsDataUrlString;
192+
}
188193
}
189194
}
190195

0 commit comments

Comments
 (0)