Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- (function() {
- const FIELD_OF_INTEREST = 'פסיכומטרי';
- const LEAD_ORIGIN_SOURCE = 'Home_Site';
- const DOMAIN_ID = '5d0f5befc004f30274c87b2c';
- const ACTION_URL = 'https://us-east4-adoric-production.cloudfunctions.net/Support_leaderIntegration';
- function sendWebhookLead(formData) {
- var data = {
- subscribe: formData,
- referrer: document.referrer,
- country: sessionStorage.getItem('country_code_cache'),
- action: ACTION_URL,
- enctype: '#',
- method: 'GET',
- campaignData: {
- options: {
- id: allCampaignData.id,
- userId: allCampaignData.options.userId,
- domainId: DOMAIN_ID,
- accountId: allCampaignData.options.userId,
- campaignTitle: allCampaignData.options.campaignTitle,
- title: allCampaignData.options.title,
- type: allCampaignData.options.type
- }
- }
- };
- var xhr = new XMLHttpRequest();
- xhr.addEventListener('readystatechange', function() {
- if (this.readyState === 4) {
- console.log('response - ', this.responseText);
- if (window.obApi) {
- obApi('track', 'Lead Artical');
- }
- }
- });
- xhr.open('POST', 'https://app.adoric-om.com/v1/forms/webhook');
- xhr.setRequestHeader('cache-control', 'no-cache');
- xhr.send(JSON.stringify(data));
- }
- function sendAdoricLead(formData) {
- var data = {
- subscribe: formData,
- referrer: document.referrer,
- country: sessionStorage.getItem('country_code_cache'),
- campaignData: {
- options: {
- id: allCampaignData.id,
- userId: allCampaignData.options.userId,
- domainId: DOMAIN_ID,
- campaignId: allCampaignData.options.campaignId,
- accountId: allCampaignData.options.userId,
- campaignTitle: allCampaignData.options.campaignTitle,
- title: allCampaignData.options.title,
- type: allCampaignData.options.type
- }
- }
- };
- var xhr = new XMLHttpRequest();
- xhr.addEventListener('readystatechange', function() {
- if (this.readyState === 4) {
- console.log('response - ', this.responseText);
- }
- });
- xhr.open('POST', 'https://app.adoric-om.com/v1/forms/leads/subscribe', true);
- xhr.send(JSON.stringify(data));
- }
- function getCookie(cname) {
- var name = cname + "=";
- var decodedCookie = decodeURIComponent(encodeURIComponent(document.cookie));
- var ca = decodedCookie.split(';');
- for (var i = 0; i < ca.length; i++) {
- var c = ca[i];
- while (c.charAt(0) == ' ') {
- c = c.substring(1);
- }
- if (c.indexOf(name) == 0) {
- return c.substring(name.length, c.length);
- }
- }
- return "";
- }
- function getLbIdentifier() {
- var lbData = null;
- adoric.lightboxes.forEach(function(item) {
- if (item.options.campaignId === self.campaignId) {
- lbData = item;
- }
- });
- return lbData;
- }
- var form = document.querySelector('.' + self.identifier + ' [tabindex] form');
- var allCampaignData = getLbIdentifier();
- form.addEventListener('submit', function() {
- var name = form.querySelector('INPUT[name="fname"]');
- var phone = form.querySelector('INPUT[name="phone"]');
- var email = form.querySelector('INPUT[type="email"]');
- var apiKey = form.querySelector('INPUT[type="adoricApiKey"]');
- const DYNAMIC_FIELDS_LIST = ['utm_source', 'utm_campaign', 'utm_term', 'utm_content', 'utm_medium', 'AdPos', 'device', 'GeoLoc', 'content_site', 'AgId', 'cid', 'gclid', 'fbclid'];
- var formData = {
- field_of_interest: FIELD_OF_INTEREST,
- Formtype: 'Adoric',
- theurl: window.location.href,
- lead_origin_source: LEAD_ORIGIN_SOURCE,
- agree: 1
- };
- if (name) {
- formData.Fname = name.value;
- }
- if (phone) {
- formData.Phone = phone.value;
- }
- if (email) {
- formData.Email = email.value;
- }
- DYNAMIC_FIELDS_LIST.forEach(item => {
- if (getCookie('cc_' + item)) {
- formData[item] = getCookie('cc_' + item);
- }
- });
- if (apiKey) {
- formData.adoricApiKey = apiKey;
- } else {
- formData.adoricApiKey = '1637152141706';
- }
- formData.userId = allCampaignData.options.userId;
- formData.adoricSessionParams = '{}';
- formData.header = '{}';
- sendWebhookLead(formData);
- sendAdoricLead(formData);
- });
- })();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement