Skip to content

Commit b1d272a

Browse files
authored
Merge pull request #56 from AddSearch/sc-8500/change-default-value-for-consentAddSearchCookie
change consentAddSearchCookie default value
2 parents 4b31ba5 + 37ccabd commit b1d272a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,10 @@ client.enablePersonalizationTracking(isEnabled, expirationDates);
352352

353353

354354
#### Allow storing AddSearch's user token in cookie
355-
By default, the value is true. Set it to false when users reject cookie (AddSearch's cookie can be categorized as functional/analytics cookie).
355+
By default, the value is false. Set it to false when users reject cookie (AddSearch's cookie can be categorized as functional/analytics cookie), or set to true when user accepts cookie.
356356
```js
357-
// Default: true
358-
client.consentAddSearchCookie(false);
357+
// Default: false
358+
client.consentAddSearchCookie(true);
359359
```
360360

361361

src/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,16 @@ var client = function(sitekey, privatekey) {
205205
this.setThrottleTime = function(delay) {this.settings.setThrottleTime(delay);}
206206
this.setStatsSessionId = function(id) {
207207
this.sessionId = id;
208-
this.userTokenInPersonalization = null;
208+
this.userTokenInPersonalization = id;
209+
this.useStatsSessionId = true;
209210
}
210211
this.getStatsSessionId = function() {return this.sessionId;}
211212
this.enableLogicalOperators = function(enableLogicalOperators) {this.settings.enableLogicalOperators(enableLogicalOperators)};
212213
this.setSearchOperator = function(operator) {this.settings.setSearchOperator(operator)};
213214

214215
this.sendStatsEvent = function(type, keyword, data) {
215216

216-
var useUserTokenInCookie = this.userTokenInPersonalization && isPersonalizationTrackingEnabled && isAddSearchCookieConsented;
217+
var useUserTokenInCookie = !this.useStatsSessionId && isPersonalizationTrackingEnabled && isAddSearchCookieConsented;
217218
if (useUserTokenInCookie && !cookie.getCookie(USER_TOKEN_COOKIE_NAME)) {
218219
cookie.setCookie(USER_TOKEN_COOKIE_NAME, this.userTokenInPersonalization, personalizationCookieExpireDays);
219220
}
@@ -250,7 +251,7 @@ var client = function(sitekey, privatekey) {
250251
* Personalization
251252
*/
252253
var isPersonalizationTrackingEnabled = false;
253-
var isAddSearchCookieConsented = true;
254+
var isAddSearchCookieConsented = false;
254255
var personalizationCookieExpireDays = 180;
255256

256257
this.getUserTokenInPersonalization = function() {

0 commit comments

Comments
 (0)