Journeys¶
generate_generic_sale_journey(start_date, fuzzy_offset=10, revenue=100)¶
This returns a journey
to be used with visit.create_pages
.
The journey will go from Home page all the way to Confirmation, adding a Sale Event.
fuzzy_offset
will alter each page view and event created from the previous timestamp starting from start_date
.
revenue
will be used in the final sale_event
.
v = Visitor(VisitDefaults.FIRST_VISIT.value, VisitDefaults.LAST_VISIT.value, account_token=AccountDefaults.TOKEN)
v.create_visit('www.google.com', Pattern.SEO.value, 1)\
.create_pages(generate_generic_sale_journey(start_date=v.first_visit))
v.insert(connection)
generate_generic_journey(start_date, fuzzy_offset=10, journey_index=None)¶
This returns a random journey
to be used with visit.create_pages
. It will some times add a non sale event
during the process.
v = Visitor(VisitDefaults.FIRST_VISIT.value, VisitDefaults.LAST_VISIT.value, account_token=AccountDefaults.TOKEN)
v.create_visit('www.google.com', Pattern.SEO.value, 1)\
.create_pages(generate_generic_journey(start_date=v.first_visit, journey_index=1))
v.insert(connection)
build_visitor_journey(channels, start_date, end_date, is_sale=False, channel_weighting=None)¶
This is a helper function to be used with generate_day_of_journeys
. Given the properties passed in it will generate a Visitor
with Visits
and Pages
from a Channel
and give it either a sale or non-sale journey
.
generate_day_of_journeys(connection, start_date=arrow.utcnow().floor('day'), end_date=arrow.utcnow().ceil('day'), fuzzy_offset=10, max_visitors=100, channel_weighting=[15, 30, 30, 5, 1, 10, 10, 5]):¶
This will build a day of journeys, with sale and non sale split by 20/80.
The channel_weighting
is relative to the Pattern, and will be used in that order.
See Python's random.choices() for more information.
This means, given max_visitors
of 100, 80 will be non sale journeys, and 20 will be sale.
We only pass channel_weighting
to the sale journey generator which means of the 20 sales: 15% will be Direct, 30% PPC and SEO etc...
This function will automatically insert these Visitors too, and returns 2 arrays of visitors: non_sale
and sale
.
non_sale_visitors, sale_visitors = generate_day_of_journeys(connection)