mod-build 3.4.12-beta.3 → 3.4.13-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/scripts/qs-form.js +36 -21
package/package.json
CHANGED
package/src/scripts/qs-form.js
CHANGED
|
@@ -422,6 +422,7 @@ modForm.initQSForm = function() {
|
|
|
422
422
|
this.opts.websiteName = window.location.host;
|
|
423
423
|
this.opts.resultsPage = (this.opts.resultsPage ? this.opts.resultsPage : '/my/results/');
|
|
424
424
|
this.opts.errorRedirectPath = (this.opts.errorRedirectPath ? this.opts.errorRedirectPath : '/my/results/');
|
|
425
|
+
this.opts.landingPage = window.location.hostname + window.location.pathname;
|
|
425
426
|
this.opts.quadLinkParams = {};
|
|
426
427
|
|
|
427
428
|
// We check if there's a quad link on the query string
|
|
@@ -672,13 +673,14 @@ modForm.submitFormDataToQSApi = function(formData, successCallback, errorCallbac
|
|
|
672
673
|
*/
|
|
673
674
|
modForm.processQSFormSubmitSuccess = function(response, xhr) {
|
|
674
675
|
var cookieData,
|
|
675
|
-
responseData = response.RESPONSE
|
|
676
|
+
responseData = response.RESPONSE,
|
|
677
|
+
dataCaptureKey = responseData.DCK;
|
|
678
|
+
|
|
679
|
+
window.projectId = responseData.HASHEDDCK;
|
|
676
680
|
|
|
677
681
|
// If submission was succesful
|
|
678
|
-
if (
|
|
679
|
-
var
|
|
680
|
-
clickKeyUUID = this.opts.formData.CLK,
|
|
681
|
-
landingPage = window.location.hostname + window.location.pathname;
|
|
682
|
+
if (dataCaptureKey != null && xhr.status === 200) {
|
|
683
|
+
var clickKeyUUID = this.opts.formData.CLK;
|
|
682
684
|
|
|
683
685
|
// Setting GA User ID and several custom dimensions after a successful form submit request
|
|
684
686
|
if (typeof dataLayer !== 'undefined') {
|
|
@@ -704,7 +706,7 @@ modForm.processQSFormSubmitSuccess = function(response, xhr) {
|
|
|
704
706
|
// eslint-disable-next-line camelcase
|
|
705
707
|
project_id: dataCaptureKey,
|
|
706
708
|
// eslint-disable-next-line camelcase
|
|
707
|
-
form_path: landingPage,
|
|
709
|
+
form_path: this.opts.landingPage,
|
|
708
710
|
qsclickkey: clickKeyUUID
|
|
709
711
|
});
|
|
710
712
|
|
|
@@ -756,16 +758,16 @@ modForm.processQSFormSubmitSuccess = function(response, xhr) {
|
|
|
756
758
|
}
|
|
757
759
|
}
|
|
758
760
|
|
|
759
|
-
// Set results page to HRC if the site is eligible
|
|
760
|
-
|
|
761
|
-
|
|
761
|
+
// Set results page to HRC if the site is eligible, there's a DCK
|
|
762
|
+
// and the results page opt is not defined yet (emerging trades have results page defined and should not redirect to the HRC)
|
|
763
|
+
if (this.isQsSiteEligibleForHrc() && window.projectId && !this.opts.resultsPage) {
|
|
762
764
|
this.opts.resultsPage = this.getProjExUrl();
|
|
763
|
-
this.opts.resultsPage += (this.opts.resultsPage.indexOf('?') < 0 ? '?' : '&') + 'DCK=' +
|
|
765
|
+
this.opts.resultsPage += (this.opts.resultsPage.indexOf('?') < 0 ? '?' : '&') + 'DCK=' + dataCaptureKey;
|
|
766
|
+
}
|
|
764
767
|
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
}
|
|
768
|
+
// Append TY to HRC URL for QS tracking purpose
|
|
769
|
+
if (typeof this.opts.appendTyToHrcUrl !== 'undefined' && this.opts.appendTyToHrcUrl === true) {
|
|
770
|
+
this.opts.resultsPage += '&' + (responseData.MATCHES.length > 0 ? 'ThankYou' : 'Sorry');
|
|
769
771
|
}
|
|
770
772
|
|
|
771
773
|
// Renamed thankyou page to results page to be more explicit that TYP is dying
|
|
@@ -793,11 +795,24 @@ modForm.processQSFormSubmitSuccess = function(response, xhr) {
|
|
|
793
795
|
* @returns {Boolean}
|
|
794
796
|
*/
|
|
795
797
|
modForm.isQsSiteEligibleForHrc = function() {
|
|
796
|
-
var
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
798
|
+
var landingPage = this.opts.landingPage,
|
|
799
|
+
eligibleDomains = [
|
|
800
|
+
'modernize.local',
|
|
801
|
+
'qa.modernize.com',
|
|
802
|
+
'modernize.com'
|
|
803
|
+
],
|
|
804
|
+
nonEligiblePaths = [
|
|
805
|
+
'gutter-guards',
|
|
806
|
+
'home-warranty',
|
|
807
|
+
'home-security',
|
|
808
|
+
'medicalalerts',
|
|
809
|
+
'bathandshowerremodel'
|
|
810
|
+
];
|
|
811
|
+
|
|
812
|
+
var isEligible = (eligibleDomains.indexOf(this.getDefaultSiteByDomain()) > -1 &&
|
|
813
|
+
!nonEligiblePaths.some(function(path) {
|
|
814
|
+
return landingPage.indexOf(path) > -1;
|
|
815
|
+
}));
|
|
816
|
+
|
|
817
|
+
return isEligible;
|
|
803
818
|
};
|