neo4j cypher conversion rate calculation

106 views Asked by At

i want to calculate please a "funnel conversion rate" on my neo4j db,

between start page , end page and list of pages in the middle, in the same user's session

the data structure is : (pseudo)

(page{page name})<--(hit{hit id})-->(User{userId})

and between hits in the same session there is a "NEXT" relationship:

(h1{hit_id}) -[:Next] ->(h2)

here is an data example: http://console.neo4j.org/r/8wnskw

what im looking for is result in the following structure:

for that i will need to fetch all possible paths, steps inside each path with the number of unique users for each step (I think its the best way)

here is a possible example for result i would like to achieve:

Array of paths: (steps in each path are separated by >)

[

"home page" :100 users > "about us page": 20 users > "register page":10 users > "buy page" : 3 users ,

"home page" :30 users > "why us page": 17 users > "register page" > "buy page" : 3 users ,

"home page" :40 users > "register page" :12 users > "buy page" : 3 users , ..... ]

explanation of the example:

first path: "home page" :100 distinct users > "about us page": 20 distinct users > "register page" > "buy page" : 3 users

means that 100 users went to home page, then- 20 continued to "about us", then - 10 users visited the register page, and out of them only 2 bought the product. so the conversion rate of this path is 2/100 = 2%

the second path has conversion rate of: 3/30

1

There are 1 answers

2
sgp On

Your question does not clearly state your schema and what exactly you need to query. From what I gather from the question, you need to find all the paths originating from "home page" to "buy page". For that something like this would work:

match p = () - [r*] - ()
return relationships(p)