Advertisement
NikolayBezay

Untitled

Nov 12th, 2021
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. <script>
  2. (function() {
  3. function getLbIdentifier(campaignId) {
  4. var lbIdentifier = null;
  5. window.adoric && adoric.lightboxes.forEach(function(item) {
  6. if (item.options.campaignId === campaignId) {
  7. lbIdentifier = item.identifier;
  8. }
  9. });
  10. return lbIdentifier;
  11. }
  12. var allCampaignData = getLbIdentifier(self.campaignId);
  13. var form = document.querySelector('.' + self.identifier + ' FORM.inner-element');
  14. var firstNameField = form.querySelector('INPUT[name="firstName"]');
  15. var lastNameField = form.querySelector('INPUT[name="lastName"]');
  16. var emailField = form.querySelector('INPUT[name="email"]');
  17. var phoneField = form.querySelector('INPUT[name="sms_phone_number"]');
  18. var birthdayField = form.querySelector('INPUT[name="birthday"]');
  19. var marketingAllowedINput = form.querySelector('INPUT[name="marketingAllowed"]');
  20. try {
  21. form.addEventListener('submit', function() {
  22. var data = {
  23. subscribe: {
  24. firstName: firstNameField.value,
  25. lastName: lastNameField.value,
  26. email: emailField.value,
  27. tags: 'Adoric',
  28. marketingAllowed: marketingAllowedINput.value,
  29. properties: {
  30. phone: phoneField.value,
  31. birth_date: birthdayField.value
  32. },
  33. userId: '5e4ea052e98c750012b2c583',
  34. adoricApiKey: "1635110566828"
  35. },
  36. referrer: '',
  37. country: '',
  38. action: 'https://app.remarkety.com/api/v1/stores/Emqzjg4w/contacts',
  39. enctype: '#',
  40. method: 'POST',
  41. campaignData: {
  42. options: {
  43. id: allCampaignData.id,
  44. userId: allCampaignData.options.userId,
  45. domainId: allCampaignData.statistic.domainId,
  46. accountId: allCampaignData.options.userId,
  47. campaignTitle: allCampaignData.options.campaignTitle,
  48. title: allCampaignData.options.title,
  49. type: allCampaignData.options.type
  50. }
  51. }
  52. };
  53. var xhr = new XMLHttpRequest();
  54. xhr.addEventListener('readystatechange', function() {
  55. var response = JSON.parse(this.responseText);
  56. if (this.readyState === 4) {
  57. var response = JSON.parse(this.responseText);
  58. console.log('response - ', response);
  59. }
  60. });
  61. xhr.open('POST', 'https://app.adoric-om.com/v1/forms/webhook');
  62. xhr.setRequestHeader('cache-control', 'no-cache');
  63. xhr.send(JSON.stringify(data));
  64. });
  65. } catch(error) {
  66. console.log('Error - ', error);
  67. }
  68. })();
  69. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement