Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- (function() {
- var productCodes = {
- CNICON: 'ICON MASCARA',
- CNLIP: 'LIP COLOR',
- CNINK: 'INKLINER',
- CNEYE: 'EYE PENCIL',
- CNBROW: 'BROW PEN',
- CNINF: 'INFINITY'
- };
- function getLbIdentifier(campaignId) {
- var lbIdentifier = null;
- window.adoric && adoric.lightboxes.forEach(function(item) {
- if (item.options.campaignId === campaignId) {
- lbIdentifier = item;
- }
- });
- return lbIdentifier;
- }
- var userCoupone = window.adoricUserCoupone;
- var allCampaignData = getLbIdentifier(self.campaignId);
- var form = document.querySelector('.' + self.identifier + ' FORM.inner-element');
- var firstNameField = form.querySelector('INPUT[name="firstName"]');
- var emailField = form.querySelector('INPUT[name="email"]');
- var phoneField = form.querySelector('INPUT[name="phone"]');
- var tagsField = form.querySelector('INPUT[name="tags"]');
- tagsField.value = 'ADORIC GIFT - ' + productCodes[userCoupone];
- try {
- form.addEventListener('submit', function() {
- var data = {
- subscribe: {
- firstName: firstNameField.value,
- email: emailField.value,
- tags: tagsField.value,
- properties: {
- phone: phoneField.value,
- },
- userId: '5d21a205eff2e800127a41bb',
- adoricApiKey: "1564327075730"
- },
- referrer: '',
- country: '',
- action: 'https://app.remarkety.com/api/v1/stores/RmxBBbaY/contacts',
- enctype: '#',
- method: 'POST',
- campaignData: {
- options: {
- id: allCampaignData.id,
- userId: '5d21a205eff2e800127a41bb',
- domainId: '5d2326f79c71fc00b2f83099',
- accountId: allCampaignData.options.userId,
- campaignTitle: allCampaignData.options.campaignTitle,
- title: allCampaignData.options.title,
- type: allCampaignData.options.type
- }
- }
- };
- var xhr = new XMLHttpRequest();
- xhr.addEventListener('readystatechange', function() {
- var response = JSON.parse(this.responseText);
- if (this.readyState === 4) {
- var response = JSON.parse(this.responseText);
- console.log('response - ', response);
- }
- });
- xhr.open('POST', 'https://app.adoric-om.com/v1/forms/webhook');
- xhr.setRequestHeader('cache-control', 'no-cache');
- xhr.send(JSON.stringify(data));
- });
- } catch (error) {
- console.log('Error - ', error);
- }
- })();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement