Segment.Spec.Order (Peacemaker v3.3.5-rc.7) View Source
Builds a token for interfacing with the Order Completed tracking event on Segment.
You can check out the Segment docs for more information
Example Usage:
alias Segment.Spec.{Order, Product}
alias Segment.Tracker
product = PeacemakerV2.Products.get_product_attributes("TW-INV-REI-01", "16")
order_total = "49.00"
order_id = 1
campaign_id = "16"
product_sku = "TW-INV-REI-01"
Order.build()
|> Order.add_product(campaign_id: campaign_id, product_sku: product_sku)
|> Order.set_revenue(order_total)
|> Order.set_order_id(order_id)
|> Order.set_user_id(Peacemaker.Accounts.find_one(email: "kawika@wealthfit.com"))
|> Order.set_event("Order Completed")
|> Tracker.send_event()
Link to this section Summary
Functions
Adds an %Product{} to the list of products
Creates a token that will be used to track billable events.
Sets the store or affiliation from which this transaction occurred (e.g. Google Store)
Sets the transaction coupon redeemed with the transaction
Sets the currency code associated with the transaction
Sets the total discount associated with the transaction
Sets the event name
Sets the Order/transaction ID
Sets the revenue ($) associated with the transaction (excluding shipping and tax)
Sets the shipping cost associated with the transaction
Sets the total tax associated with the transaction
Sets the revenue ($) with discounts and coupons added in. Note that our Google Analytics Ecommerce destination accepts total or revenue, but not both. For better flexibility and total control over tracking, we let you decide how to calculate how coupons and discounts are applied
Sets the user_id.
Link to this section Types
Specs
Specs
set_user_id_request() :: [email: String.t(), user_id: String.t() | nil] | %Peacemaker.Account{ __meta__: term(), account_playlist: term(), account_playlist_id: term(), active_order_id: term(), allowed_classes: term(), allowed_courses: term(), allowed_intensives: term(), allowed_live_classes: term(), birthdate: term(), cancellations: term(), course_permissions: term(), customer_id: term(), email: term(), enrollments: term(), first_name: term(), goals: term(), goto_registrant: term(), has_completed_capture_fb_billing_funnel: term(), has_completed_onboarding_funnel: term(), has_completed_wootric_survey: term(), has_lifetime_accelleration: term(), has_set_initial_password: term(), has_you_plus_two_permissions: term(), hourly_rate: term(), id: term(), infusion_contact_id: term(), inserted_at: term(), is_starter_program_member: term(), just_created: term(), last_login_date: term(), last_name: term(), on_hold_start_date: term(), orders: term(), password: term(), permissions: term(), phone: term(), preferences: term(), prospect_id: term(), referrals: term(), reset_password_token: term(), role: term(), starter_program_no_cc: term(), subscription_inactive_reason: term(), temp_pw: term(), timezone: term(), updated_at: term(), user_profile: term(), user_profile_id: term(), user_type: term(), video_progressions: term() }
Specs
Link to this section Functions
Specs
add_product(t(), Segment.Spec.Product.t()) :: t()
add_product(t(), Keyword.t(campaign_id: String.t(), product_sku: String.t())) :: t()
add_product(t(), get_product_attributes()) :: t()
Adds an %Product{} to the list of products
Specs
build(%{}) ::
%Segment.Spec.Order{
affiliation: term(),
coupon: term(),
currency: term(),
discount: term(),
event: term(),
order_id: term(),
products: term(),
revenue: term(),
shipping: term(),
tax: term(),
total: term(),
user_id: term()
}
| {:error, %{event: [String.t()]}}
Creates a token that will be used to track billable events.
Specs
Sets the store or affiliation from which this transaction occurred (e.g. Google Store)
Specs
Sets the transaction coupon redeemed with the transaction
Specs
Sets the currency code associated with the transaction
For a list of valid currency codes, check out the docs here
Specs
Sets the total discount associated with the transaction
Specs
Sets the event name
Specs
set_order_id(t(), String.t() | pos_integer()) :: t()
Sets the Order/transaction ID
Specs
Sets the revenue ($) associated with the transaction (excluding shipping and tax)
Specs
Sets the shipping cost associated with the transaction
Specs
Sets the total tax associated with the transaction
Specs
Sets the revenue ($) with discounts and coupons added in. Note that our Google Analytics Ecommerce destination accepts total or revenue, but not both. For better flexibility and total control over tracking, we let you decide how to calculate how coupons and discounts are applied
Specs
set_user_id(
%Segment.Spec.Order{
affiliation: term(),
coupon: term(),
currency: term(),
discount: term(),
event: term(),
order_id: term(),
products: term(),
revenue: term(),
shipping: term(),
tax: term(),
total: term(),
user_id: term()
},
set_user_id_request()
) :: %Segment.Spec.Order{
affiliation: term(),
coupon: term(),
currency: term(),
discount: term(),
event: term(),
order_id: term(),
products: term(),
revenue: term(),
shipping: term(),
tax: term(),
total: term(),
user_id: term()
}
Sets the user_id.
#TODO: When the WealthFit Prospect ID is added, update these docs