Tue Mar 05 2019
Copied to clipboard! Copy reply
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
<script>
/************************************************************
GDPR EMAIL CONSENT INITIALIZER

Instructions to activate email consent on your page (after this initalizer code runs):

	1) Put the following HTML anywhere you want an email consent checkbox (there can be more than one per page):
		<div class="gdpr_target"></div>

	   Note:
	   	If this is a newsletter signup, use <div class="gdpr_newsletter_disclaimer"></div>

	2) Update your page's email submission code (usually in submitEmailToEC function)

		a) paste this variable where you need to check consent:
			var gdpr_consent_given = window.gdpr && window.gdpr.email_consent; // note: US country_code sets consent to 'implicit'

		b for DEMO signups) block email submission if user hasn't consented:
			if(!gdpr_consent_given){ skip email and go directly to demo }
			else if(gdpr_consent_given){ proceed as normal }

		b for NEWSLETTER signups) set consent to active by default (unless user is from double opt-in country)

			// if user is from a double opt-in country
			if(window.gdpr){
				if( (window.gdpr.double_opt_in_countries).indexOf(window.gdpr.country_code) > -1 ){
					window.gdpr.email_consent = 'double_opt_in';
				}
				else{
					window.gdpr.email_consent = 'active';
				}
			}
		
		c) add this to your email collection form data:
			consent_type : ( window.gdpr && window.gdpr.email_consent ) || null

	3) Update briteverify email verification function by adding this code (or something similar) near the top of the function:

		// if gdpr consent isn't given, skip the validation and go straight to the demo
		var gdpr_consent_given = window.gdpr && window.gdpr.email_consent && window.gdpr.email_consent != null;
		if(!gdpr_consent_given){
			success_callback();
			return;
		}

*************************************************************/

(function () {
	if (window.gdpr) {

		window.gdpr.run_checkbox_code = function () {

			window.gdpr.state.checkbox_code_ran = true;

			if (document.readyState === 'complete' || document.readyState === 'interactive') {
				insert_GDPR_email_checkbox('.gdpr_target', '.gdpr_newsletter_disclaimer');
			}
			else {
				document.addEventListener('DOMContentLoaded', function () {
					insert_GDPR_email_checkbox('.gdpr_target', '.gdpr_newsletter_disclaimer');
				});
			}
			get_GDPR_email_consent(window.gdpr.country_code);
		};



		// ************************************************************
		// RUN EMAIL CONSENT SCRIPT AT CORRECT TIMES
		// ************************************************************

		// if country code has already returned, run checkbox code
		if (window.gdpr.state.country_code_returned) {
			if (!window.gdpr.state.checkbox_code_ran) {
				window.gdpr.run_checkbox_code();
			}
		}

		// run email consent when country code returns
		window.gdpr.on('country_code_returned', function () {
			if (!window.gdpr.state.checkbox_code_ran) {
				window.gdpr.run_checkbox_code();
			}
		});

		// if country code takes too long, run email consent code as if non-US
		setTimeout(function () {
			if (!window.gdpr.state.checkbox_code_ran) {
				window.gdpr.run_checkbox_code();
			}
		}, window.gdpr.max_wait_for_country_code);





		// use for testing if you need this outside of dtm ---------
		/*window.gdpr = window.gdpr || {
			email_consent: null,
			country_code: get_country_code(window.location.href)
		};

		function get_country_code(url){
			return (url.match(/[&?]country=([^&]+)/i) || [])[1];
		}*/
		// end testing section -------------------------------------



		function insert_GDPR_email_checkbox(checkbox_target_selector, newsletter_target_selector) {
			// make sure checkbox only shows for non-US visitors
			var country_code = window.gdpr && window.gdpr.country_code || '';
			var isNotUS = !(country_code && country_code.toUpperCase() === 'US')
			var checkbox_disclaimer_elems = document.querySelectorAll(checkbox_target_selector);
			var newsletter_disclaimer_elems = document.querySelectorAll(newsletter_target_selector);

			if (isNotUS) {
				if (checkbox_disclaimer_elems) {
					insert_GDPR_checkboxes(checkbox_disclaimer_elems);
				}
				if (newsletter_disclaimer_elems) {
					insert_GDPR_newsletter_notices(newsletter_disclaimer_elems);
				}
				insert_GDPR_styles();
				add_checkbox_listeners();
				add_more_info_listeners();
			}
		}

		function insert_GDPR_styles() {
			var gdpr_styles = document.createElement('style');
			var gdpr_checkbox_css = '' +
				'.gdpr_container{' +
					'font-size: 16px;' +
					'text-align: left;' +
					'color: #333;' +
					'background-color: #f8f6f0;' +
					'padding: 20px;' +
					'margin: 10px auto;' +
					'line-height: 1.3;' +
					'max-width: 473px;' +
					'border: 1px solid #eaeaea;' +
				'}' +
				'.gdpr_checkbox_label{' +
					'cursor: pointer;' +
				'}' +
				'.gdpr_checkbox{' +
					'cursor: pointer;' +
				'}' +
				'.gdpr_more_info_link{' +
					'color: #0098db;' +
					'text-decoration: underline;' +
				'}' +
				'.gdpr_more_info_text{' +
					'display: none;' +
					'text-align: left;' +
					'font-size: 0.8em;' +
					'margin-top: 10px;' +
				'}' +
				'.gdpr_more_info_text a{' +
					'color: #0098db;' +
					'text-decoration: underline;' +
				'}' +
				'.gdpr_more_info_text_show{' +
					'display: block;' +
				'}' +
				'p.gdpr_checkbox_label{' +
					'width: 100%;' +
				'}' +
				'';
			gdpr_styles.innerHTML = gdpr_checkbox_css;
			document.querySelector('head').appendChild(gdpr_styles);
		}

		// --------------------------------------------------------
		// email consent language switcher - start
		// --------------------------------------------------------
		function getConsentText(consent_lang) {
			consent_lang = consent_lang || 'en-US';
			var is_espanol_site = document.querySelector('html').lang.toLowerCase() === 'es-us';
			if (is_espanol_site) {
				consent_lang = 'es-US';
			}
			var consent_text = {
				'en-US': {
					topline_checkbox: 'Yes! I would like to receive product updates and marketing from Rosetta Stone. ',
					topline_newsletter: 'By signing up for this newsletter, I agree to receive product updates and marketing from Rosetta Stone. ',
					more_info_link: 'Click here for more information.',
					more_info: 'By confirming, I agree to receive information and marketing relating to news, updates on Rosetta Stone products and services, offers, and invitations to events from Rosetta Stone, and I understand and agree that Rosetta Stone may process and transfer my information to its affiliates globally and to third party entities that provide services to Rosetta Stone for such purposes, in accordance with Rosetta Stone\'s <a href="https://www.rosettastone.com/privacy" target="_blank">Privacy Policy</a>. I understand that I may opt-out of such communications at any time by clicking the link provided in the communication or by contacting Rosetta Stone at <a href="mailto:privacyofficer@rosettastone.com?Subject=Privacy%20inquiry">privacyofficer@rosettastone.com</a>.'
				},
				'es-US': {
					topline_checkbox: 'Quiero recibir información sobre las novedades de los productos y las ofertas de Rosetta Stone. ',
					topline_newsletter: 'Al suscribirme a este boletín, acepto recibir información y ofertas de Rosetta Stone. ',
					more_info_link: 'Saber más.',
					more_info: 'Acepto recibir información y material de marketing sobre novedades del producto, ofertas e invitaciones a eventos de Rosetta Stone. Soy consciente de que Rosetta Stone puede compartir mis datos de acuerdo <a href="https://espanol.rosettastone.com/privacy" target="_blank">la política de protección de datos de Rosetta Stone</a> con socios globales y con terceros, los cuales ofrezcan servicios a Rosetta Stone. También soy consciente de que puedo anular en cualquier momento cualquier tipo de comunicación con Rosetta Stone haciendo clic sobre el enlace &ldquo;Anular suscripción&rdquo; que aparece en el material de marketing o contactando con Rosetta Stone en <a href="mailto:privacyofficer@rosettastone.com?Subject=Privacy%20inquiry">privacyofficer@rosettastone.com</a>.'
				}
			};

			return consent_text[consent_lang];
		}
		// --------------------------------------------------------
		// email consent language switcher - end
		// --------------------------------------------------------




		function insert_GDPR_checkboxes(elems) {

			var consent_text = getConsentText();

			// place gdpr checkboxes
			Array.prototype.forEach.call(elems, function (elem) {

				var gdpr_checkbox_html = '' +
					'<div class="gdpr_container" data-qa="gdpr_email_consent_container">' +
						'<label class="gdpr_checkbox_label">' +
							'<input class="gdpr_checkbox" data-qa="gdpr_email_consent_checkbox" type="checkbox" autocomplete="off" style="width:auto; height:auto; margin:auto 6px auto auto; border:unset; display:inline-block;">' +
							consent_text.topline_checkbox +
						'</label>' +
						'<a href="#" class="gdpr_more_info_link">' + consent_text.more_info_link + '</a>' +
						'<div class="gdpr_more_info_text">' +
							consent_text.more_info +
						'</div>' +
					'</div>';

				elem.innerHTML = gdpr_checkbox_html;
			});
		}

		function insert_GDPR_newsletter_notices(elems) {

			var consent_text = getConsentText();

			// place gdpr checkboxes
			Array.prototype.forEach.call(elems, function (elem) {

				var gdpr_newsletter_html = '' +
					'<div class="gdpr_container" data-qa="gdpr_email_consent_container">' +
						'<p class="gdpr_checkbox_label">' +
							consent_text.topline_newsletter +
							'<a href="#" class="gdpr_more_info_link">' + consent_text.more_info_link + '</a>' +
						'</p>' +
						'<div class="gdpr_more_info_text">' +
							consent_text.more_info +
						'</div>' +
					'</div>';

				elem.innerHTML = gdpr_newsletter_html;
			});
		}

		function add_checkbox_listeners() {
			// add event listeners to checkboxes
			var checkbox_elems = document.querySelectorAll('.gdpr_checkbox');
			Array.prototype.forEach.call(checkbox_elems, function (checkbox) {

				checkbox.addEventListener('change', function () {
					var current_country_code = window.gdpr.country_code;
					if (this.checked) {
						var needs_double_opt_in = window.gdpr.double_opt_in_countries
							.indexOf(current_country_code) > -1;
						window.gdpr.email_consent = needs_double_opt_in ?
							'double_opt_in' : 'explicit';
					} else {
						window.gdpr.email_consent = null;
					}
				});
			});
		}

		function add_more_info_listeners() {
			// add event listeners to "more info" links
			var more_info_links = document.querySelectorAll(
				'.gdpr_more_info_link');
			Array.prototype.forEach.call(more_info_links, function (
				info_link) {

				info_link.addEventListener('click', function (e) {
					e.preventDefault();

					var info_text = info_link.parentElement.parentElement
						.querySelector('.gdpr_more_info_text');

					info_text.className = (/gdpr_more_info_text_show/).test(
							info_text.className) ?
						info_text.className.replace(
							/ gdpr_more_info_text_show/, '') :
						info_text.className + ' gdpr_more_info_text_show';
				});
			});
		}

		function get_GDPR_email_consent(country_code) {
			// default is gdpr compliant, so US is the only one that should change
			if (country_code && country_code.toUpperCase() === 'US') {

				// allow email collection
				window.gdpr.email_consent = 'implicit';

				// hide gdpr content
				Array.prototype.forEach.call(document.querySelectorAll(
					'.gdpr_target'), function (elem) {
					elem.style.display = 'none';
				});
			}
		}

		// expose methods on gdpr global
		window.gdpr.insert_GDPR_email_checkbox = insert_GDPR_email_checkbox;
		window.gdpr.insert_GDPR_styles = insert_GDPR_styles;
		window.gdpr.insert_GDPR_checkboxes = insert_GDPR_checkboxes;
		window.gdpr.insert_GDPR_newsletter_notices = insert_GDPR_newsletter_notices;
		window.gdpr.add_checkbox_listeners = add_checkbox_listeners;
		window.gdpr.add_more_info_listeners = add_more_info_listeners;
		window.gdpr.get_GDPR_email_consent = get_GDPR_email_consent;
	}
})();
</script>