I have some data around a website where the website has different shop sections but when the user checks out at the end, we only know what shop section it is by looking for their most recent section hit
For example if I have data that looks like
session, hit_number, page a,1,homepage a,2,generic_page a,3,shoe_store, a,4,buy_add_basket a,5,buy_checkout b,1,sock_store b,2,shoe_store, b,3,buy_add_to_basket b,4,buy_checkout c,1,homepage c,2,sock_store c,3,sock_store c,4,buy_add_to_basket c,5,home_page c,6,shoe_store a,5,home_page
I want to persist the last store they went to (where exists and only for when they are in a buy section of the webpage (i.e. page name start with "buy")
Output I am expecting is:
session, hit_number, page a,1,homepage,null a,2,generic_page,null a,3,shoe_store,null a,4,buy_add_basket,shoe_store a,5,buy_checkout,shoe_store b,1,sock_store,null b,2,shoe_store,null b,3,buy_add_to_basket,shoe_store b,4,buy_checkout,shoe_store c,1,homepage,null c,2,sock_store,null c,3,sock_store,null c,4,buy_add_to_basket,sock_store, c,5,home_page,null c,6,shoe_store,null a,5,home_page,null