Skip to content

Instantly share code, notes, and snippets.

@dramsay
Last active July 17, 2019 16:00
Show Gist options
  • Save dramsay/288cdc15a8616ca7cbff651e03bbb7d3 to your computer and use it in GitHub Desktop.
Save dramsay/288cdc15a8616ca7cbff651e03bbb7d3 to your computer and use it in GitHub Desktop.
Barometric example
order_id = '066b507c-984d-11e9-b068-0b0f7dbba186'
o = Order.find('066b507c-984d-11e9-b068-0b0f7dbba186')
o.title
o.attribution_type = Order.attribution_types[:barometric]
o.attribution_project_id = 6815
o.attribution_exposure_group_id = 100712
o.attribution_control_group_id = -1
o.generate_control_groups(0)
o.save!
require 'cgi'
def add_to_barometric(order_id, url)
puts order_id
puts url
o = Order.find(order_id)
query_hash = CGI.parse(URI.parse(url).query)
attribution_project_id = Array(query_hash['c']).first
attribution_exposure_group_id = Array(query_hash['p']).first
raise ArgumentError, 'Invalid URL' if [attribution_project_id, attribution_exposure_group_id].any?(&:blank?)
puts "\tAdding attribution project id: #{attribution_project_id}, attribution exposure group id #{attribution_exposure_group_id}"
o.attribution_type = Order.attribution_types[:barometric]
o.attribution_project_id = attribution_project_id
o.attribution_exposure_group_id = attribution_exposure_group_id
o.attribution_control_group_id = -1
o.generate_control_groups(0)
o.save!
puts "\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment