Last active
December 15, 2025 11:31
-
-
Save cw6365/bc178fb18b31d0c643e06e0850b0da1c to your computer and use it in GitHub Desktop.
Mappings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| COMPANY_NAME: 'company' | |
| UUID: 'uuid__legacy_' | |
| JOB_TITLE: 'jobtitle' | |
| TRIAL: 'in_trial' | |
| VISITOR_ID: 'visitor_id__legacy_' | |
| SOURCE: 'source__legacy_' | |
| REFERRER: 'referrer' | |
| CAMPAIGN: 'campaign__legacy_' | |
| MEDIUM: 'medium__legacy_' | |
| KEYWORDS: 'keywords__legacy_' | |
| LANDING_PAGE: 'landing_page__legacy_' | |
| ADWORD_GROUP: 'adword_group__legacy_' | |
| MATCH_TYPE: 'match_type__legacy_' | |
| CONTACT_METHOD: 'contact_method__legacy_' | |
| DEVICE: 'device__legacy_' | |
| GOOGLE_CLICK_ID: 'hs_google_click_id' | |
| BING_CLICK_ID: 'bing_click_id__legacy_' | |
| OWNER_ID: 78639646 | |
| PLAN_NAME: 'plan_name' | |
| WEBSITE_LEAD: 'website_lead' | |
| FREE_TRIAL_REQUESTED: 'free_trial_requested' | |
| TRANSACTION_ID: 'transaction_id' | |
| customer build: | |
| uuid = contact_form? || demo_form? ? nil : @data_service.user.uuid | |
| trial = contact_form? || demo_form? ? "No" : "Yes" | |
| contact_method = contact_form? ? "Sales Form Submission" : "" | |
| { | |
| firstname: split_name(@data_service.options[:form_data][:"Full Name"])[0], | |
| lastname: split_name(@data_service.options[:form_data][:"Full Name"])[1], | |
| email: @data_service.options[:form_data][:Email], | |
| phone: @data_service.options[:form_data][:"phone-number"], | |
| "#{@config[:COMPANY_NAME]}": @data_service.options[:form_data][:"company-name"], | |
| "#{@config[:UUID]}": uuid, # user uuid | |
| "#{@config[:JOB_TITLE]}": @data_service.options[:form_data][:"Job Title"], # job title | |
| "#{@config[:TRANSACTION_ID]}": @data_service.options[:form_data][:transaction_id], | |
| "#{@config[:TRIAL]}": trial, # free trial | |
| "#{@config[:VISITOR_ID]}": @data_service.options[:id], # visitor id | |
| "#{@config[:REFERRER]}": @data_service.options[:referrer], # referrer url | |
| "#{@config[:CAMPAIGN]}": @data_service.options[:campaign], # campaign | |
| "#{@config[:MEDIUM]}": @data_service.options[:medium], # medium | |
| "#{@config[:KEYWORDS]}": @data_service.options[:keywords], | |
| "#{@config[:LANDING_PAGE]}": @data_service.options[:landing_page_url], | |
| "#{@config[:GOOGLE_CLICK_ID]}": @data_service.options.dig(:milestones, :first_touch, :landing_page_url_params, :gclid) || @data_service.options.dig(:milestones, :first_touch, :referrer_url_params, :gclid), | |
| "#{@config[:BING_CLICK_ID]}": @data_service.options.dig(:milestones, :first_touch, :landing_page_url_params, :msclkid) || @data_service.options.dig(:milestones, :first_touch, :referrer_url_params, :msclkid), | |
| "#{@config[:ADWORD_GROUP]}": parse_landing_page(@data_service.options[:landing_page_url], "adgroupid"), | |
| "#{@config[:MATCH_TYPE]}": parse_landing_page(@data_service.options[:landing_page_url], "matchtype"), | |
| "#{@config[:DEVICE]}": parse_landing_page(@data_service.options[:landing_page_url], "device"), | |
| "#{@config[:WEBSITE_LEAD]}": "No", | |
| "#{@config[:CONTACT_METHOD]}": contact_method | |
| } | |
| deal build: | |
| body = { | |
| "properties": { | |
| "dealname": purchase.pretty_name, | |
| "amount": payment.amount.to_f, | |
| "pipeline": pipeline, | |
| "deal_currency_code": payment.currency.upcase, | |
| "dealstage": dealstage | |
| }, | |
| "associations": [ | |
| { | |
| "to": { | |
| "id": record["company"]["hs_object_id"] | |
| }, | |
| "types": [ | |
| { | |
| "associationCategory": "HUBSPOT_DEFINED", | |
| "associationTypeId": 341 # find company association | |
| } | |
| ] | |
| }, | |
| { | |
| "to": { | |
| "id": record["hs_object_id"] | |
| }, | |
| "types": [ | |
| { | |
| "associationCategory": "HUBSPOT_DEFINED", | |
| "associationTypeId": 3 # find contact association | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| res = HubspotAPI.crm.deals.basic_api.create(body: body) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment