feat: set register conversion cookie (#380)

Set register conversion cookie upon successful registration to fire
social conversion pixels in GTM.
This commit is contained in:
Waheed Ahmed
2021-07-01 14:49:48 +05:00
parent 5fe1866e21
commit a2bf4e3226
8 changed files with 13 additions and 3 deletions

1
.env
View File

@@ -22,3 +22,4 @@ COOKIE_DOMAIN=null
WELCOME_PAGE_SUPPORT_LINK=null
INFO_EMAIL=''
DISABLE_ENTERPRISE_LOGIN=''
REGISTER_CONVERSION_COOKIE_NAME=null

View File

@@ -30,3 +30,4 @@ WELCOME_PAGE_SUPPORT_LINK='http://localhost:1999/welcome'
INFO_EMAIL='info@edx.org'
DISABLE_ENTERPRISE_LOGIN=''
DEFAULT_DESIGN='legacy'
REGISTER_CONVERSION_COOKIE_NAME='openedx-user-register-conversion'

View File

@@ -21,3 +21,4 @@ LOGIN_ISSUE_SUPPORT_LINK='https://login-issue-support-url.com'
USER_SURVEY_COOKIE_NAME='openedx-user-survey-type'
WELCOME_PAGE_SUPPORT_LINK='http://localhost:1999/welcome'
DISABLE_ENTERPRISE_LOGIN=''
REGISTER_CONVERSION_COOKIE_NAME='openedx-user-register-conversion'

View File

@@ -55,6 +55,7 @@ initialize({
WELCOME_PAGE_SUPPORT_LINK: process.env.WELCOME_PAGE_SUPPORT_LINK || null,
DISABLE_ENTERPRISE_LOGIN: process.env.DISABLE_ENTERPRISE_LOGIN || '',
INFO_EMAIL: process.env.INFO_EMAIL || '',
REGISTER_CONVERSION_COOKIE_NAME: process.env.REGISTER_CONVERSION_COOKIE_NAME || null,
});
},
},

View File

@@ -32,7 +32,7 @@ import {
DEFAULT_STATE, LOGIN_PAGE, PENDING_STATE, REGISTER_PAGE, VALID_EMAIL_REGEX,
} from '../data/constants';
import {
getTpaProvider, getTpaHint, updatePathWithQueryParams, getAllPossibleQueryParam, setSurveyCookie,
getTpaProvider, getTpaHint, updatePathWithQueryParams, getAllPossibleQueryParam, setSurveyCookie, setCookie,
} from '../data/utils';
class RegistrationPage extends React.Component {
@@ -452,6 +452,7 @@ class RegistrationPage extends React.Component {
if (this.props.registrationResult.success) {
setSurveyCookie('register');
setCookie(getConfig().REGISTER_CONVERSION_COOKIE_NAME, true);
// Fire optimizely events
window.optimizely = window.optimizely || [];

View File

@@ -30,6 +30,7 @@ describe('RegistrationPageTests', () => {
REGISTRATION_OPTIONAL_FIELDS: 'gender,goals,level_of_education,year_of_birth',
TOS_AND_HONOR_CODE: 'http://tos-and-honot-code.com',
USER_SURVEY_COOKIE_NAME: process.env.USER_SURVEY_COOKIE_NAME,
REGISTER_CONVERSION_COOKIE_NAME: process.env.REGISTER_CONVERSION_COOKIE_NAME,
});
const initialState = {
@@ -577,6 +578,7 @@ describe('RegistrationPageTests', () => {
renderer.create(reduxWrapper(<IntlRegistrationPage />));
expect(document.cookie).toMatch(`${getConfig().USER_SURVEY_COOKIE_NAME}=register`);
expect(document.cookie).toMatch(`${getConfig().REGISTER_CONVERSION_COOKIE_NAME}=true`);
});
it('should display institution register button', () => {

View File

@@ -41,7 +41,7 @@ import {
DEFAULT_STATE, PENDING_STATE, REGISTER_PAGE, VALID_EMAIL_REGEX, LETTER_REGEX, NUMBER_REGEX,
} from '../data/constants';
import {
getTpaProvider, getTpaHint, getAllPossibleQueryParam, setSurveyCookie,
getTpaProvider, getTpaHint, getAllPossibleQueryParam, setSurveyCookie, setCookie,
} from '../data/utils';
import CountryDropdown from './CountryDropdown';
import getLevenshteinSuggestion from './utils';
@@ -476,9 +476,10 @@ class RegistrationPage extends React.Component {
if (this.props.registrationResult.success) {
setSurveyCookie('register');
window.optimizely = window.optimizely || [];
setCookie(getConfig().REGISTER_CONVERSION_COOKIE_NAME, true);
// Fire optimizely events
window.optimizely = window.optimizely || [];
window.optimizely.push({
type: 'event',
eventName: 'authn-register-conversion',

View File

@@ -37,6 +37,7 @@ describe('RegistrationPage', () => {
REGISTRATION_OPTIONAL_FIELDS: 'gender,goals,levelOfEducation,yearOfBirth',
TOS_AND_HONOR_CODE: 'http://tos-and-honot-code.com',
USER_SURVEY_COOKIE_NAME: process.env.USER_SURVEY_COOKIE_NAME,
REGISTER_CONVERSION_COOKIE_NAME: process.env.REGISTER_CONVERSION_COOKIE_NAME,
});
let props = {};
@@ -486,6 +487,7 @@ describe('RegistrationPage', () => {
renderer.create(reduxWrapper(<IntlRegistrationPage {...props} />));
expect(document.cookie).toMatch(`${getConfig().USER_SURVEY_COOKIE_NAME}=register`);
expect(document.cookie).toMatch(`${getConfig().REGISTER_CONVERSION_COOKIE_NAME}=true`);
});
it('should show username suggestions in case of conflict with an existing username', () => {