# ML model that is most suited to analyse Google Analytics data

Google Analytics allows me to collect data about every web-session. For simplicity, let's assume for each user, we collect the number of pages and time spent on site for each session:

user_id visit_id page_views time_spent result
1       1        10         100        0
1       2        31         510        0
1       3        1          10         1


How would you model this data? What I would like the ML algorithm to do:

1. Extract as much information as possible
2. Have a flexible number of inputs (e.g. the number of sessions can go to infinity)

What I can think of:

1. Aggregate the data per user e.g. average page_views or total page_views and feed it into a general algorithm e.g. random forrest (but I lose information with aggregation)
2. Use LSTM and feed at most last 3 visits (will also lose information, but would this perform better than aggregation?)

Goal: To build a predictive model to analyse all user sessions and make a prediction whether the person will convert or not.

• Your goal is so vague and unclear. The title and introduction is about Google Analytics data but you end with a goal about predicting whether or not a person will convert or not. What is 'result'? What does 'extract as much information as possible' mean? Is your page a site to convert a person's ideology or religion? If so what are the people doing on your site? Are they filling out forms or taking surveys? Is the data dynamic? – Brian O'Donnell Mar 7 '18 at 22:48

I understand that in your example you are interested in modelling the outcome of the 'result' column.

One easy model I would suggest is to model it using the Bernoulli distribution (https://en.wikipedia.org/wiki/Bernoulli_distribution) with the probability of success p.

Then you can model p with something like this

x = a + b * log(page_views) + c * log(time_spent) + e

p = exp(x) / (1+exp(x))

where e is normally distributed, e ~ N(0, sigma^2) (or simply centered around zero).

a, b and c are parameters that you can estimate.

I.e. the probability of success (conversion) is modeled as a sigma function of a certain variable that depends on page_views and time_spend. You can also add squares (and higher powers) of page_views and time_spend in the equation of x (i.e. upto a certain threshold page_views can have a positive effect on conversion and then a negative one, then again a positive effect).

Also reading about logistic regression should put you on the right track: https://en.wikipedia.org/wiki/Logistic_regression

I would model this data as a 3d-tensor (user,timestep,features) [organization depends on which DL Framework you use] for your input data. Also for the output data is a 3d-tensor (user,timestep,result) appropriate.

The next step would ne tp train a LSTM or CNN model to predict the result (what requires a lot of data)(Would be my first choice). If you have less data, try out logistic regression as supposed by the other answer.

Good luck!