- 31st Jul 2024
- 06:03 am
In this assignment the analysis delves into the site flow from the homepage to the confirmation page, focusing on user abandonment points and conversion rates. By examining mobile and desktop performance, conversion probabilities for each page, and potential improvements, we aim to uncover actionable insights to enhance overall user experience and conversion rates. Site flow - Homepage -> Search Page -> product selection takes you to payment page -> confirmation page
- Where and when our users abandoned the website?
- What is the conversion Rate from Mobile and Desktop? What’s the Conversion probability for each page? Conversion Rate by page by device.
- What can help improve conversion rates?
- Any additional insights to draw from data about new users?
Free Assignment Solution - Analyzing User Flow And Conversion Rates
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "jfWKU-akOcxn"
},
"source": [
"## Funnel Analysis Project"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "gUBZIbCYOcxp"
},
"source": [
"### Import Libraries and Load datasets"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"id": "6Oogq3U5Ocxo"
},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"plt.style.use('ggplot')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"id": "M7rA8dITOcxp"
},
"outputs": [],
"source": [
"user = pd.read_csv('user_table.csv')\n",
"home = pd.read_csv('home_page_table.csv')\n",
"search = pd.read_csv('search_page_table.csv')\n",
"payment = pd.read_csv('payment_page_table.csv')\n",
"payment_confirm = pd.read_csv('payment_confirmation_table.csv')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 206
},
"id": "t3q4K9rzOcxp",
"outputId": "b1fe5e2d-e600-4661-8df9-e4ff761e8511"
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" user_id date device sex\n",
"0 450007 2015-02-28 Desktop Female\n",
"1 756838 2015-01-13 Desktop Male\n",
"2 568983 2015-04-09 Desktop Male\n",
"3 190794 2015-02-18 Desktop Female\n",
"4 537909 2015-01-15 Desktop Male"
],
"text/html": [
"\n",
"
"
"
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
user_id | date | device | sex | |
---|---|---|---|---|
0 | 450007 | 2015-02-28 | Desktop | Female |
1 | 756838 | 2015-01-13 | Desktop | Male |
2 | 568983 | 2015-04-09 | Desktop | Male |
3 | 190794 | 2015-02-18 | Desktop | Female |
4 | 537909 | 2015-01-15 | Desktop | Male |
"
" " title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" " width=\"24px\">\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"
"
\n",
" "
]
},
"metadata": {},
"execution_count": 4
}
],
"source": [
"user.head()"
]
},
{
"cell_type": "code",
"source": [
"home.head()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 206
},
"id": "9NIz_-YrQaOw",
"outputId": "8104efc5-c651-466f-ca8f-595f17eff67d"
},
"execution_count": 5,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" user_id page\n",
"0 313593 home_page\n",
"1 468315 home_page\n",
"2 264005 home_page\n",
"3 290784 home_page\n",
"4 639104 home_page"
],
"text/html": [
"\n",
"
"
"
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
user_id | page | |
---|---|---|
0 | 313593 | home_page |
1 | 468315 | home_page |
2 | 264005 | home_page |
3 | 290784 | home_page |
4 | 639104 | home_page |
"
" " title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" " width=\"24px\">\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"
"
\n",
" "
]
},
"metadata": {},
"execution_count": 5
}
]
},
{
"cell_type": "code",
"source": [
"search.head()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 206
},
"id": "ECPJH4yvQcxQ",
"outputId": "3741dad3-35cb-41c2-bf68-47f3dbc6d27a"
},
"execution_count": 6,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" user_id page\n",
"0 15866 search_page\n",
"1 347058 search_page\n",
"2 577020 search_page\n",
"3 780347 search_page\n",
"4 383739 search_page"
],
"text/html": [
"\n",
"
"
"
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
user_id | page | |
---|---|---|
0 | 15866 | search_page |
1 | 347058 | search_page |
2 | 577020 | search_page |
3 | 780347 | search_page |
4 | 383739 | search_page |
"
" " title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" " width=\"24px\">\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"
"
\n",
" "
]
},
"metadata": {},
"execution_count": 6
}
]
},
{
"cell_type": "code",
"source": [
"payment.head()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 206
},
"id": "lvIQGzALQd5H",
"outputId": "74f58055-f7f5-4c36-f7a2-c94db9af339c"
},
"execution_count": 7,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" user_id page\n",
"0 253019 payment_page\n",
"1 310478 payment_page\n",
"2 304081 payment_page\n",
"3 901286 payment_page\n",
"4 195052 payment_page"
],
"text/html": [
"\n",
"
"
"
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
user_id | page | |
---|---|---|
0 | 253019 | payment_page |
1 | 310478 | payment_page |
2 | 304081 | payment_page |
3 | 901286 | payment_page |
4 | 195052 | payment_page |
"
" " title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" " width=\"24px\">\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"
"
\n",
" "
]
},
"metadata": {},
"execution_count": 7
}
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 206
},
"id": "uWXfiwfHOcxp",
"outputId": "2a7a9ab9-7f3d-4e93-f948-0d800296028a"
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" user_id page\n",
"0 123100 payment_confirmation_page\n",
"1 704999 payment_confirmation_page\n",
"2 407188 payment_confirmation_page\n",
"3 538348 payment_confirmation_page\n",
"4 841681 payment_confirmation_page"
],
"text/html": [
"\n",
"
"
"
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
user_id | page | |
---|---|---|
0 | 123100 | payment_confirmation_page |
1 | 704999 | payment_confirmation_page |
2 | 407188 | payment_confirmation_page |
3 | 538348 | payment_confirmation_page |
4 | 841681 | payment_confirmation_page |
"
" " title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" " width=\"24px\">\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"
"
\n",
" "
]
},
"metadata": {},
"execution_count": 8
}
],
"source": [
"payment_confirm.head()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "BCUwG0tMOcxq"
},
"source": [
"## Data processing\n",
"\n",
"We will now be merging the datasets using pandas merge method to combine them into a single dataset. This way we can have all the information of all the users at a single place!"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"id": "v6z9BW6uOcxq"
},
"outputs": [],
"source": [
"data = pd.merge(left=user, right=home, how='left', on='user_id')"
]
},
{
"cell_type": "code",
"source": [
"data = pd.merge(left=data, right=search, how='left', on='user_id', suffixes=('_home', '_search'))"
],
"metadata": {
"id": "G4us3k_fQoXb"
},
"execution_count": 10,
"outputs": []
},
{
"cell_type": "code",
"source": [
"data = pd.merge(left=data, right=payment, how='left', on='user_id')"
],
"metadata": {
"id": "QdlGXMabQqk2"
},
"execution_count": 11,
"outputs": []
},
{
"cell_type": "code",
"source": [
"data = pd.merge(left=data, right=payment_confirm, how='left', on='user_id', suffixes=('_payment', '_confirmation'))"
],
"metadata": {
"id": "2qVMPYykQruB"
},
"execution_count": 12,
"outputs": []
},
{
"cell_type": "code",
"source": [
"data.head()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 206
},
"id": "DMj--WKLQtIo",
"outputId": "f19171de-e6f7-4d45-9446-bcf06bc2812a"
},
"execution_count": 13,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" user_id date device sex page_home page_search page_payment \\\n",
"0 450007 2015-02-28 Desktop Female home_page NaN NaN \n",
"1 756838 2015-01-13 Desktop Male home_page NaN NaN \n",
"2 568983 2015-04-09 Desktop Male home_page search_page NaN \n",
"3 190794 2015-02-18 Desktop Female home_page search_page NaN \n",
"4 537909 2015-01-15 Desktop Male home_page NaN NaN \n",
"\n",
" page_confirmation \n",
"0 NaN \n",
"1 NaN \n",
"2 NaN \n",
"3 NaN \n",
"4 NaN "
],
"text/html": [
"\n",
"
"
"
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
user_id | date | device | sex | page_home | page_search | page_payment | page_confirmation | |
---|---|---|---|---|---|---|---|---|
0 | 450007 | 2015-02-28 | Desktop | Female | home_page | NaN | NaN | NaN |
1 | 756838 | 2015-01-13 | Desktop | Male | home_page | NaN | NaN | NaN |
2 | 568983 | 2015-04-09 | Desktop | Male | home_page | search_page | NaN | NaN |
3 | 190794 | 2015-02-18 | Desktop | Female | home_page | search_page | NaN | NaN |
4 | 537909 | 2015-01-15 | Desktop | Male | home_page | NaN | NaN | NaN |
"
" " title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" " width=\"24px\">\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"
"
\n",
" "
]
},
"metadata": {},
"execution_count": 13
}
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "bdleTVUROcxq",
"outputId": "14d2bc4a-aaad-44fa-e1cd-d0016b3aa431"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\n",
"Int64Index: 90400 entries, 0 to 90399\n",
"Data columns (total 8 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 user_id 90400 non-null int64 \n",
" 1 date 90400 non-null object\n",
" 2 device 90400 non-null object\n",
" 3 sex 90400 non-null object\n",
" 4 page_home 90400 non-null object\n",
" 5 page_search 45200 non-null object\n",
" 6 page_payment 6030 non-null object\n",
" 7 page_confirmation 452 non-null object\n",
"dtypes: int64(1), object(7)\n",
"memory usage: 6.2+ MB\n"
]
}
],
"source": [
"data.info()"
]
},
{
"cell_type": "markdown",
"source": [
"This information shows that of all the users (90400), all of them reached the home page (obviously). Now, only 45200 reached search page, 6030 reached payment page and hardly 452 users reached the payment confirmation page."
],
"metadata": {
"id": "CAj8Q6hqRXzX"
}
},
{
"cell_type": "markdown",
"metadata": {
"id": "PFS5V-JkOcxr"
},
"source": [
"## Data analysis"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "5j9v2-8eOcxr"
},
"source": [
"So, using the above information, we will find out the visit probability for each page. This is simple. We just divide the number of users in that page by the total number of users."
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 175
},
"id": "OFAj5Q8lOcxr",
"outputId": "124ac000-a2ad-46db-f926-39571337f6d2"
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" index conversion\n",
"4 page_home 1.000000\n",
"5 page_search 0.500000\n",
"6 page_payment 0.066704\n",
"7 page_confirmation 0.005000"
],
"text/html": [
"\n",
"
"
"
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
index | conversion | |
---|---|---|
4 | page_home | 1.000000 |
5 | page_search | 0.500000 |
6 | page_payment | 0.066704 |
7 | page_confirmation | 0.005000 |
"
" " title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" " width=\"24px\">\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"
"
\n",
" "
]
},
"metadata": {},
"execution_count": 15
}
],
"source": [
"probability = 1 - pd.DataFrame(data.isnull().sum()).rename(columns={0: 'conversion'}) / len(data)\n",
"probability = probability.reset_index()[4:]\n",
"probability"
]
},
{
"cell_type": "markdown",
"source": [
"We find that the conversion ratio for home page = 1, for search page it is 45200/90400 = 0.5, for payment page it is 6030/90400 = 0.0667, and finally for the payment confirmation it is 452/90400 = 0.005 "
],
"metadata": {
"id": "08l41mggS4T4"
}
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 338
},
"id": "Uk3dIzv4Ocxr",
"outputId": "375c5702-3411-42bc-a02f-13377c8d48d9"
},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
""
],
"image/png":
"metadata": {
"needs_background": "light"
}
}
],
"source": [
"fig, ax = plt.subplots(figsize=(8, 5))\n",
"sns.barplot(x='index', y='conversion', data=probability, ax=ax)\n",
"ax.set_xlabel('Page', fontsize=12)\n",
"ax.set_ylabel('Users Ratio', fontsize=12)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "hWDbXxctOcxr"
},
"source": [
"## 2. Conversion Rate for Each Page"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"id": "VdAA6S_wOcxs"
},
"outputs": [],
"source": [
"def conversion_rate(df):\n",
" \"\"\"\n",
" Using this function, we will calculate the \n",
" conversion rates for home page, search page and payments page\n",
" for different groups of devices (which includes desktop,\n",
" mobile and both)\n",
" \"\"\"\n",
" values = []\n",
" new = df[~df['page_home'].isnull()]\n",
" values.append(1 - new['page_search'].isnull().sum() / len(new)) \n",
" new = df[~df['page_search'].isnull()]\n",
" values.append(1 - new['page_payment'].isnull().sum() / len(new)) \n",
" new = df[~df['page_payment'].isnull()]\n",
" values.append(1 - new['page_confirmation'].isnull().sum() / len(new)) \n",
" return values"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Z1NPaxeUOcxs"
},
"source": [
"### Both Desktop and Mobile"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"id": "wuG-cxkPOcxs"
},
"outputs": [],
"source": [
"rates = conversion_rate(data)\n",
"names = ['home', 'search', 'payment']"
]
},
{
"cell_type": "code",
"source": [
"connect = {'Page': ['home', 'search', 'payment'], \n",
" 'Conversion Rate': rates}\n",
"both = pd.DataFrame(connect, columns=['Page', 'Conversion Rate'])\n",
"both"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 143
},
"id": "q7kIAG84VE_S",
"outputId": "e69c6d73-503a-4a40-c105-29ee1fda35ae"
},
"execution_count": 24,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" Page Conversion Rate\n",
"0 home 0.500000\n",
"1 search 0.133407\n",
"2 payment 0.074959"
],
"text/html": [
"\n",
" \n",
" \n",
" \n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
PageConversion Rate0home0.5000001search0.1334072payment0.074959
\n",
"\n",
" " title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" " width=\"24px\">\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
" \n",
" \n",
" "
]
},
"metadata": {},
"execution_count": 24
}
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 337
},
"id": "9lqZOnyVOcxs",
"outputId": "f997e2c2-942b-4dd2-a7ee-b4f61d71a9b1"
},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
""
],
"image/png":
"metadata": {
"needs_background": "light"
}
}
],
"source": [
"fig, ax = plt.subplots(figsize=(6, 5))\n",
"sns.barplot(x='Page', y='Conversion Rate', data=both, ax=ax)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"source": [
"For both the devices, conversion rate for home is 0.5, for search page it is 0.13341 and for the payment page it is 0.075."
],
"metadata": {
"id": "SghZG___VMDG"
}
},
{
"cell_type": "markdown",
"metadata": {
"id": "WnmDxu0nOcxs"
},
"source": [
"### Now we will calculate these value for Desktop and Mobile separately"
]
},
{
"cell_type": "markdown",
"source": [
"### Desktop"
],
"metadata": {
"id": "iqKt3iLHWC2V"
}
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {
"id": "rcgLzcX6Ocxs"
},
"outputs": [],
"source": [
"desk_rates = conversion_rate(data[data['device'] == 'Desktop'])\n",
"mobile_rates = conversion_rate(data[data['device'] == 'Mobile'])"
]
},
{
"cell_type": "code",
"source": [
"names = ['home', 'search', 'payment']\n",
"connect = {'Page': ['home', 'search', 'payment'], \n",
" 'Conversion Rate': desk_rates}\n",
"desktop = pd.DataFrame(connect, columns=['Page', 'Conversion Rate'])\n",
"desktop"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 143
},
"id": "4kYjYX9EV0hf",
"outputId": "732a7382-3168-4c33-9988-16849efbd731"
},
"execution_count": 29,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" Page Conversion Rate\n",
"0 home 0.500000\n",
"1 search 0.100000\n",
"2 payment 0.049834"
],
"text/html": [
"\n",
" \n",
" \n",
" \n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
PageConversion Rate0home0.5000001search0.1000002payment0.049834
\n",
"\n",
" " title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" " width=\"24px\">\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
" \n",
" \n",
" "
]
},
"metadata": {},
"execution_count": 29
}
]
},
{
"cell_type": "markdown",
"source": [
"### Mobile"
],
"metadata": {
"id": "Vmv6BDPxWEzU"
}
},
{
"cell_type": "code",
"source": [
"names = ['home', 'search', 'payment']\n",
"connect = {'Page': ['home', 'search', 'payment'], \n",
" 'Conversion Rate': mobile_rates}\n",
"mobile = pd.DataFrame(connect, columns=['Page', 'Conversion Rate'])\n",
"mobile"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 143
},
"id": "2LC0F3YOV_PT",
"outputId": "da6bd7fc-7415-41ef-b6ab-9c65f13f8a43"
},
"execution_count": 30,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" Page Conversion Rate\n",
"0 home 0.5\n",
"1 search 0.2\n",
"2 payment 0.1"
],
"text/html": [
"\n",
" \n",
" \n",
" \n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
PageConversion Rate0home0.51search0.22payment0.1
\n",
"\n",
" " title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" " width=\"24px\">\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
" \n",
" \n",
" "
]
},
"metadata": {},
"execution_count": 30
}
]
},
{
"cell_type": "markdown",
"source": [
"For desktop devices, conversion rate for home is 0.5, for search page it is 0.1 and for the payment page it is 0.045 whereas for mobile devices, conversion rate for home is 0.5, for search page it is 0.2 and for the payment page it is 0.1."
],
"metadata": {
"id": "td_igs76WTBi"
}
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 238
},
"id": "FyPOQYTBOcxt",
"outputId": "3d8ef78a-3b1c-41be-ad0e-aef8d92553aa"
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" Page Device Conversion Rate\n",
"0 home Desktop 0.500000\n",
"1 search Desktop 0.100000\n",
"2 payment Desktop 0.049834\n",
"3 home Mobile 0.500000\n",
"4 search Mobile 0.200000\n",
"5 payment Mobile 0.100000"
],
"text/html": [
"\n",
" \n",
" \n",
" \n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
PageDeviceConversion Rate0homeDesktop0.5000001searchDesktop0.1000002paymentDesktop0.0498343homeMobile0.5000004searchMobile0.2000005paymentMobile0.100000
\n",
"\n",
" " title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" " width=\"24px\">\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
" \n",
" \n",
" "
]
},
"metadata": {},
"execution_count": 40
}
],
"source": [
"connect = {'Page': ['home', 'search', 'payment']*2, \n",
" 'Device': ['Desktop']*3 + ['Mobile']*3, \n",
" 'Conversion Rate': desk_rates + mobile_rates}\n",
"all_dev = pd.DataFrame(connect, columns=['Page', 'Device', 'Conversion Rate'])\n",
"all_dev"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 337
},
"id": "3XXtYMySOcxt",
"outputId": "3fe3762f-7977-4305-93a4-456949a745ac"
},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
""
],
"image/png":
},
"metadata": {
"needs_background": "light"
}
}
],
"source": [
"fig, ax = plt.subplots(figsize=(6, 5))\n",
"sns.barplot(x='Page', y='Conversion Rate', \n",
" data=all_dev, ax=ax, hue='Device')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "3HNuRjR6Ocxt"
},
"source": [
"### Now we will calculate these value for Gender (Male and Female) separately"
]
},
{
"cell_type": "markdown",
"source": [
"### Male"
],
"metadata": {
"id": "X-lPqNYwZtmH"
}
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {
"id": "7Tp3BMkVOcxt"
},
"outputs": [],
"source": [
"male_rates = conversion_rate(data[data['sex'] == 'Male'])"
]
},
{
"cell_type": "code",
"source": [
"names = ['home', 'search', 'payment']\n",
"connect = {'Page': ['home', 'search', 'payment'], \n",
" 'Conversion Rate': male_rates}\n",
"male = pd.DataFrame(connect, columns=['Page', 'Conversion Rate'])\n",
"male"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 143
},
"id": "_Xsk-zkyaNI3",
"outputId": "9635b2f8-59e3-4f20-dd0a-db78188ee455"
},
"execution_count": 42,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" Page Conversion Rate\n",
"0 home 0.496944\n",
"1 search 0.130083\n",
"2 payment 0.072014"
],
"text/html": [
"\n",
" \n",
" \n",
" \n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
PageConversion Rate0home0.4969441search0.1300832payment0.072014
\n",
"\n",
" " title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" " width=\"24px\">\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
" \n",
" \n",
" "
]
},
"metadata": {},
"execution_count": 42
}
]
},
{
"cell_type": "code",
"source": [
"female_rates = conversion_rate(data[data['sex'] == 'Female'])"
],
"metadata": {
"id": "7NDAI2oOaT48"
},
"execution_count": 43,
"outputs": []
},
{
"cell_type": "code",
"source": [
"names = ['home', 'search', 'payment']\n",
"connect = {'Page': ['home', 'search', 'payment'], \n",
" 'Conversion Rate': female_rates}\n",
"female = pd.DataFrame(connect, columns=['Page', 'Conversion Rate'])\n",
"female"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 143
},
"id": "qrl7SlnmaXIg",
"outputId": "58bd4159-2d38-416f-a648-5891293be128"
},
"execution_count": 44,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" Page Conversion Rate\n",
"0 home 0.503073\n",
"1 search 0.136708\n",
"2 payment 0.077742"
],
"text/html": [
"\n",
" \n",
" \n",
" \n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
PageConversion Rate0home0.5030731search0.1367082payment0.077742
\n",
"\n",
" " title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" " width=\"24px\">\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
" \n",
" \n",
" "
]
},
"metadata": {},
"execution_count": 44
}
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 238
},
"id": "eJVMkysHOcxt",
"outputId": "790cba84-e9af-4ea5-83b9-2bceb517b919"
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" Page Sex Conversion Rate\n",
"0 home Male 0.496944\n",
"1 search Male 0.130083\n",
"2 payment Male 0.072014\n",
"3 home Female 0.503073\n",
"4 search Female 0.136708\n",
"5 payment Female 0.077742"
],
"text/html": [
"\n",
" \n",
" \n",
" \n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
PageSexConversion Rate0homeMale0.4969441searchMale0.1300832paymentMale0.0720143homeFemale0.5030734searchFemale0.1367085paymentFemale0.077742
\n",
"\n",
" " title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" " width=\"24px\">\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
" \n",
" \n",
" "
]
},
"metadata": {},
"execution_count": 45
}
],
"source": [
"# Visualization\n",
"connect = {'Page': ['home', 'search', 'payment']*2, \n",
" 'Sex': ['Male']*3 + ['Female']*3, \n",
" 'Conversion Rate': male_rates + female_rates}\n",
"sex_conv = pd.DataFrame(connect, columns=['Page', 'Sex', 'Conversion Rate'])\n",
"sex_conv"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 337
},
"id": "xcSjEE5eOcxu",
"outputId": "623d91f3-e992-4387-86e1-037f0111dcdc"
},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
""
],
"image/png":
"cell_type": "code",
"source": [
""
],
"metadata": {
"id": "x4NxVD7reZd2"
},
"execution_count": null,
"outputs": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
},
"colab": {
"name": "Python_Aleksandra.ipynb",
"provenance": []
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Get the best Analyzing User Flow And Conversion Rates assignment help and tutoring services from our experts now!
Our team of Python experts has successfully finished this sample Python assignment. The provided solutions are intended solely for research and reference. If you find the reports and code useful, our Python tutors would be happy to help.
- For a complete solution package that includes code, reports, and screenshots, please check out our Python Assignment Sample Solution page.
- For personalized online tutoring sessions to address any questions you have about this assignment, reach out to our Python tutors.
- For additional insights, explore the partial solution available in the blog above.
About The Author - Taylor Morgan
Taylor Morgan is a data analyst with a specialization in e-commerce and user experience optimization. With extensive experience in analyzing site flow and conversion rates, Taylor excels in identifying user abandonment points and assessing conversion rates across devices. Their insights into improving conversion rates and understanding new user behavior are backed by a solid foundation in data-driven strategies and analytics.