{"id":27381961,"url":"https://github.com/theng23/e-commerce-website-performance-analysis-sql","last_synced_at":"2025-10-24T13:18:40.644Z","repository":{"id":272264889,"uuid":"916019490","full_name":"theng23/E-commerce-Website-Performance-Analysis-SQL","owner":"theng23","description":"Using Bigquery base on Google Analytics dataset to analyze E-commerce Website","archived":false,"fork":false,"pushed_at":"2025-04-13T10:39:32.000Z","size":192,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T15:16:32.178Z","etag":null,"topics":["bigquery","sql"],"latest_commit_sha":null,"homepage":"https://github.com/theng23/Ecommerce-Project","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theng23.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-13T09:55:35.000Z","updated_at":"2025-04-13T10:39:35.000Z","dependencies_parsed_at":"2025-01-13T10:41:05.633Z","dependency_job_id":"55edbb4b-5338-4824-9022-dd646e1323b1","html_url":"https://github.com/theng23/E-commerce-Website-Performance-Analysis-SQL","commit_stats":null,"previous_names":["theng23/ecommerce-project","theng23/e-commerce-website-performance-analysis","theng23/e-commerce-website-performance-analysis-python","theng23/e-commerce-website-performance-analysis-sql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theng23%2FE-commerce-Website-Performance-Analysis-SQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theng23%2FE-commerce-Website-Performance-Analysis-SQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theng23%2FE-commerce-Website-Performance-Analysis-SQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theng23%2FE-commerce-Website-Performance-Analysis-SQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theng23","download_url":"https://codeload.github.com/theng23/E-commerce-Website-Performance-Analysis-SQL/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248732485,"owners_count":21152852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bigquery","sql"],"created_at":"2025-04-13T15:16:51.752Z","updated_at":"2025-10-24T13:18:40.618Z","avatar_url":"https://github.com/theng23.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# 📊 E-commerce Website Performance Analysis | SQL, BigQuery\n## 📑 I. Introduction\n### 📖 What is this project about?\n✔️ This project contains an eCommerce dataset that i will explore by using SQL on Google BigQuery.\\\n✔️ The dataset is based on the Google Analytics public dataset and contains data from an eCommerce website.\\\n✔️ Using this dataset, queries are executed to analyze website activity in 2017, including calculating the bounce rate, identifying days with the highest revenue, examining user behavior on pages, and performing other forms of analysis.\n\n\n###\n\u003cdetails\u003e \n\u003csummary\u003eThe goal of creating this project:\u003c/summary\u003e\n  \n  👉🏻 Overview of website activity\\\n  👉🏻 Bounce rate analysis\\\n  👉🏻 Revenue analysis\\\n  👉🏻 Transactions analysis\\\n  👉🏻 Products analysis\n\n\u003c/details\u003e\n\n## 📜 II. Requirements\n- Google Cloud Platform account\n- Project on Google Cloud Platform\n- Google BigQuery API enabled\n- SQL query editor or IDE\n## 📂 III. Dataset Access\nThe eCommerce dataset is stored in a public Google BigQuery dataset. To access the dataset, follow these steps:\n  - Log in to your Google Cloud Platform account and create a new project.\n  - Navigate to the BigQuery console and select your newly created project.\n  - In the navigation panel, select \"Add Data\" and then \"Search a project\".\n  - Enter the project ID \"bigquery-public-data.google_analytics_sample.ga_sessions\" and click \"Enter\".\n  - Click on the \"ga_sessions_\" table to open it.\n### 📌DATASET\nhttps://support.google.com/analytics/answer/3437719?hl=en \u003cbr\u003e\n\u003cdetails\u003e\n\u003csummary\u003eTable Schema in this project:\u003c/summary\u003e\n  \n| Field Name | Data Type | Description |\n|-------|-------|-------|\n| fullVisitorId | STRING | The unique visitor ID. |\n| date | STRING | The date of the session in YYYYMMDD format. |\n| totals | RECORD | This section contains aggregate values across the session. |\n|totals.bounces|INTEGER|Total bounces (for convenience). For a bounced session, the value is 1, otherwise it is null.|\n|totals.hits|INTEGER|Total number of hits within the session.|\n|totals.pageviews|INTEGER|Total number of pageviews within the session.|\n|totals.visits|INTEGER|The number of sessions (for convenience). This value is 1 for sessions with interaction events. The value is null if there are no interaction events in the session.|\n|totals.transactions|INTEGER|Total number of ecommerce transactions within the session.|\n|trafficSource.source|STRING|The source of the traffic source. Could be the name of the search engine, the referring hostname, or a value of the utm_source URL parameter.|\n|hits|RECORD|This row and nested fields are populated for any and all types of hits.|\n|hits.eCommerceAction|RECORD|This section contains all of the ecommerce hits that occurred during the session. This is a repeated field and has an entry for each hit that was collected.|\n|hits.eCommerceAction.action_type|STRING|\"The action type. Click through of product lists = 1, Product detail views = 2, Add product(s) to cart = 3, Remove product(s) from cart = 4, Check out = 5, Completed purchase = 6, Refund of purchase = 7, Checkout options = 8, Unknown = 0.Usually this action type applies to all the products in a hit, with the following exception: when hits.product.isImpression = TRUE, the corresponding product is a product impression that is seen while the product action is taking place (i.e., a \"\"product in list view\"\").Example query to calculate number of products in list views:SELECT COUNT(hits.product.v2ProductName) FROM [foo-160803:123456789.ga_sessions_20170101] WHERE hits.product.isImpression == TRUE Example query to calculate number of products in detailed view: SELECT COUNT(hits.product.v2ProductName), FROM [foo-160803:123456789.ga_sessions_20170101] WHERE hits.ecommerceaction.action_type = '2' AND ( BOOLEAN(hits.product.isImpression) IS NULL OR BOOLEAN(hits.product.isImpression) == FALSE )\"|\n|hits.product|RECORD|This row and nested fields will be populated for each hit that contains Enhanced Ecommerce PRODUCT data.|\n|hits.product.productQuantity|INTEGER|The quantity of the product purchased.|\n|hits.product.productRevenue|INTEGER|The revenue of the product, expressed as the value passed to Analytics multiplied by 10^6 (e.g., 2.40 would be given as 2400000).|\n|hits.product.productSKU|STRING|Product SKU.|\n|hits.product.v2ProductName|STRING|Product Name.|\n\n\u003c/details\u003e\n\n\n## ⚒️ IV. Exploring the Dataset\n### **Query 01: calculate total visit, pageview, transaction for Jan, Feb and March 2017 (order by month)**\n\n- SQL Code:\n```sql\n\nSELECT \n  FORMAT_DATE(\"%Y%m\", PARSE_DATE(\"%Y%m%d\", date)) AS month, --Find Jan, Feb and March\n  SUM(totals.visits) AS visits, --total visits\n  SUM(totals.pageviews) AS pageviews, --total pagevies\n  SUM(totals.transactions) AS transactions, --total transaction\nFROM\n  `bigquery-public-data.google_analytics_sample.ga_sessions_2017*`\nWHERE\n  _TABLE_SUFFIX BETWEEN '0101' AND '0331' --condition to get month \nGROUP BY 1 \nORDER BY 1; --sorting month\n\n```\n- Result:\n\n|month|visits|pageviews|transactions|\n|-----|------|---------|------------|\n|01   |64694 |257708   |713         |\n|02   |62192 |233373   |733         |\n|03   |69931 |259522   |993         |\n\nA positive upward trend is observed across all three metrics from February to March. With February showing the lowest site visits, it may be beneficial to explore underlying factors contributing to this dip.\n### **Query 02: Bounce rate per traffic source in July 2017 (Bounce_rate = num_bounce/total_visit) (order by total_visit DESC)**\n- Bounce rate is a measures the percentage of visitors who enter a website and leave without interacting further, such as clicking a link or visiting another page.\n- SQL Code\n```sql\nSELECT\n  trafficSource.source\n  ,SUM(totals.visits) AS total_visit --total visits\n  ,SUM(totals.bounces) AS total_no_of_bounces --total bounces\n  ,ROUND(SUM(totals.bounces)/SUM(totals.visits) * 100,3) AS bounce_rate --find bounce rate\nFROM \n  `bigquery-public-data.google_analytics_sample.ga_sessions_201707*`\nGROUP BY\n  trafficSource.source\nORDER BY --sorting by total visits\n  total_visit DESC;\n\n```\n\u003cdetails\u003e\n\u003csummary\u003eTop 10 highest visits\u003c/summary\u003e\n  \n|source                     |total_visit|total_no_of_bounces|bounce_rate|\n|---------------------------|-----------|-------------------|-----------|\n|google                     |38400      |19798              |51.557     |\n|(direct)                   |19891      |8606               |43.266     |\n|youtube.com                |6351       |4238               |66.73      |\n|analytics.google.com       |1972       |1064               |53.955     |\n|Partners                   |1788       |936                |52.349     |\n|m.facebook.com             |669        |430                |64.275     |\n|google.com                 |368        |183                |49.728     |\n|dfa                        |302        |124                |41.06      |\n|sites.google.com           |230        |97                 |42.174     |\n|facebook.com               |191        |102                |53.403     |\n\n\u003c/details\u003e\n\n\nThe result presents a summary of website traffic from different sources and key metrics used to assess user engagement and behaviours. It focuses on four main elements: source, total_visits, total_no_bounces and bounce_rate.\n\nThe top source of traffic to the website is Google however significant bounce rate(51.557\u0026).Meanwhile, direct visits show a lower bounce rate (43.266%) and are the second-largest contributor to traffic. Additionally, platforms like YouTube and Facebook have high bounce rates, suggesting potential areas for improvement in user retention strategies.\n\n\n\u003cdetails\u003e\n\u003csummary\u003eTop 10 lowest visits:\u003c/summary\u003e\n\n\n\n|source                     |total_visit|total_no_of_bounces|bounce_rate|\n|---------------------------|-----------|-------------------|-----------|\n|gophergala.com             |1          |1                  |100.0      |\n|google.nl                  |1          |                   |           |\n|google.ca                  |1          |                   |           |\n|earth.google.com           |1          |                   |           |\n|newclasses.nyu.edu         |1          |                   |           |\n|kidrex.org                 |1          |1                  |100.0      |\n|kik.com                    |1          |1                  |100.0      |\n|aol                        |1          |                   |           |\n|google.es                  |1          |1                  |100.0      |\n|malaysia.search.yahoo.com  |1          |1                  |100.0      |\n\n\u003c/details\u003e\n\n\n\nSome traffic sources, like \"gophergala.com,\" \"kik.com,\" and \"malaysia.search.yahoo.com,\" show a 100% bounce rate, suggesting visitors leave immediately without further interaction. This indicates potential mismatches between user expectations and the content or landing pages for these sources, worth investigating further.\n\n### **Query 03: Revenue by traffic source by week, by month in June 2017**  \n- Revenue is the total income generated by a business through its primary operations, such as selling goods or services, before deducting any expenses.\n- SQL Code\n```sql\n  \nSELECT --find revenue by traffic by week\n    'WEEK' AS time_type\n    ,FORMAT_DATE('%Y%W',PARSE_DATE('%Y%m%d',date)) AS time\n    ,trafficSource.source\n    ,SUM(product.productRevenue) / 1000000 AS revenue --calculate revene\nFROM\n    `bigquery-public-data.google_analytics_sample.ga_sessions_201706*`\n    ,UNNEST (hits) hits\n    ,UNNEST (hits.product) product\nWHERE\n    product.productRevenue IS NOT NULL --must add this condition to ensure revenue\nGROUP BY\n  time\n  ,trafficSource.source\n\nUNION ALL --Union traffic by week and month\n\nSELECT --find revenue by traffic by month\n    'Month' AS time_type\n    ,FORMAT_DATE('%Y%m',PARSE_DATE('%Y%m%d',date)) AS time\n    ,trafficSource.source\n    ,SUM(product.productRevenue) / 1000000 AS revenue\nFROM\n    `bigquery-public-data.google_analytics_sample.ga_sessions_201706*`\n    ,UNNEST (hits) hits\n    ,UNNEST (hits.product) product\nWHERE\n    product.productRevenue is not null --must add this condition to ensure revenue\nGROUP BY\n  time\n  ,trafficSource.source\nOrder BY\n    time_type DESC;\n\n```\n\u003cdetails\u003e\n\u003csummary\u003eResults:\u003c/summary\u003e\n\n|time_type|time  |source           |revenue     |\n|---------|------|-----------------|------------|\n|WEEK     |201724|(direct)         |30908.909927|\n|WEEK     |201724|google           |9217.169976 |\n|WEEK     |201723|(direct)         |17325.679919|\n|WEEK     |201723|dfa              |1145.279998 |\n|WEEK     |201722|google           |2119.38999  |\n|WEEK     |201722|sites.google.com |13.98       |\n|WEEK     |201724|dfa              |2341.56     |\n|WEEK     |201724|dealspotr.com    |72.95       |\n|WEEK     |201725|google.com       |23.99       |\n|WEEK     |201723|search.myway.com |105.939998  |\n|WEEK     |201725|(direct)         |27295.319924|\n|WEEK     |201724|bing             |13.98       |\n|WEEK     |201722|(direct)         |6888.899975 |\n|WEEK     |201724|mail.google.com  |2486.86     |\n|WEEK     |201726|(direct)         |14914.80995 |\n|WEEK     |201726|yahoo            |20.39       |\n|WEEK     |201725|groups.google.com|38.59       |\n|WEEK     |201723|youtube.com      |16.99       |\n|WEEK     |201725|sites.google.com |25.19       |\n|WEEK     |201725|mail.aol.com     |64.849998   |\n|WEEK     |201724|l.facebook.com   |12.48       |\n|WEEK     |201725|google           |1006.099991 |\n|WEEK     |201726|google           |5330.569964 |\n|WEEK     |201726|dfa              |3704.74     |\n|WEEK     |201725|mail.google.com  |76.27       |\n|WEEK     |201725|phandroid.com    |52.95       |\n|WEEK     |201722|dfa              |1670.649998 |\n|WEEK     |201726|groups.google.com|63.37       |\n|WEEK     |201723|google           |1083.949999 |\n|WEEK     |201723|chat.google.com  |74.03       |\n|Month    |201706|google           |18757.17992 |\n|Month    |201706|mail.google.com  |2563.13     |\n|Month    |201706|dealspotr.com    |72.95       |\n|Month    |201706|phandroid.com    |52.95       |\n|Month    |201706|google.com       |23.99       |\n|Month    |201706|search.myway.com |105.939998  |\n|Month    |201706|mail.aol.com     |64.849998   |\n|Month    |201706|l.facebook.com   |12.48       |\n|Month    |201706|sites.google.com |39.17       |\n|Month    |201706|groups.google.com|101.96      |\n|Month    |201706|youtube.com      |16.99       |\n|Month    |201706|(direct)         |97333.619695|\n|Month    |201706|bing             |13.98       |\n|Month    |201706|dfa              |8862.229996 |\n|Month    |201706|yahoo            |20.39       |\n|Month    |201706|chat.google.com  |74.03       |\n\u003c/details\u003e\nThe table presents revenue data categorized by attributes such as time type, time period, source, and revenue amount. Revenue originates from various channels, including direct website visits, search traffic, and referrals from external websites.\n\n\n### **Query 04: Average number of pageviews by purchaser type (purchasers vs non-purchasers) in June, July 2017.**\n- SQL Code\n```sql\n\nWITH purchaser_data AS( --find a purchaser\n  SELECT\n      FORMAT_DATE(\"%Y%m\",PARSE_DATE(\"%Y%m%d\",date)) AS month\n      ,(SUM(totals.pageviews)/COUNT(DISTINCT fullvisitorid)) AS avg_pageviews_purchase --avgerate pageview purchase\n  FROM \n    `bigquery-public-data.google_analytics_sample.ga_sessions_2017*`\n    ,UNNEST(hits) hits\n    ,UNNEST(product) product\n  WHERE \n    _table_suffix BETWEEN '0601' AND '0731'\n    AND totals.transactions\u003e=1\n    AND product.productRevenue is not null -- must add this condition to ensure revenue\n  GROUP BY month\n),\n\nnon_purchaser_data AS( --find a non purchaser\n  SELECT\n      FORMAT_DATE(\"%Y%m\",PARSE_DATE(\"%Y%m%d\",date)) AS month\n      ,(SUM(totals.pageviews)/COUNT(DISTINCT fullvisitorid)) AS avg_pageviews_non_purchase  --avgerate pageview non purchase\n  FROM \n    `bigquery-public-data.google_analytics_sample.ga_sessions_2017*`\n    ,UNNEST(hits) hits\n    ,UNNEST(product) product\n  WHERE \n    _table_suffix BETWEEN '0601' AND '0731'\n    AND totals.transactions IS NULL\n    AND product.productRevenue IS NULL --must add this condition to ensure revenue\n  GROUP BY month\n)\n\nSELECT\n    pd.*\n    ,avg_pageviews_non_purchase\nFROM \n  purchaser_data pd\nFULL JOIN \n  non_purchaser_data\nUSING(month)\nORDER BY pd.month;\n\n```\n|month|avg_pageviews_purchase|avg_pageviews_non_purchase|\n|-----|----------------------|--------------------------|\n|201706|94.02050113895217     |316.86558846341671        |\n|201707|124.23755186721992    |334.05655979568053        |\n\nPurchasers have lower average pageviews compared to non-purchasers, but from June to July 2017, purchasers' average pageviews increased significantly by 30.22%, while non-purchasers' pageviews rose modestly by 5.42%. This suggests improved engagement for purchasers, while non-purchasers may still struggle with decision-making or navigation.\n\n### **Query 05: Average number of transactions per user that made a purchase in July 2017**\n- SQL Code\n```sql\nSELECT\n  FORMAT_DATE(\"%Y%m\",PARSE_DATE(\"%Y%m%d\",date)) AS month\n  ,SUM(totals.transactions)/COUNT(DISTINCT fullvisitorid) AS Avg_total_transactions_per_user\nFROM \n  `bigquery-public-data.google_analytics_sample.ga_sessions_201707*`\n  ,UNNEST (hits) hits\n  ,UNNEST(product) product\nWHERE\n  totals.transactions\u003e=1\n  AND product.productRevenue IS NOT NULL -- must add this condition to ensure revenue\nGROUP BY \n  month;\n\n```\n|month|Avg_total_transactions_per_user|\n|-----|-------------------------------|\n|201707|4.16390041493776               |\n\nAverage total transactions per user in July 2017 is 4.1639. This information serves to understand user behavior, monitor platform engagement levels, and assess the effectiveness of marketing efforts or promotions conducted during that period\n\n### **Query 06: Average amount of money spent per session. Only include purchaser data in July 2017**\n- SQL Code\n```sql\nSELECT\n  FORMAT_DATE('%Y%m',PARSE_DATE('%Y%m%d',date)) as month\n  ,ROUND((SUM(product.productRevenue) /SUM(totals.visits)) /1000000,3) AS avg_revenue_by_user_per_visit --avagerate revenue by user per visit\n  from \n  `bigquery-public-data.google_analytics_sample.ga_sessions_201707*`\n  ,UNNEST(hits) AS hits\n  ,UNNEST(hits.product) AS product\nWHERE\n  totals.transactions IS NOT NULL \n    AND product.productRevenue IS NOT NULL --must add this condition to ensure revenue\nGROUP BY\n  month;\n```\n|month|Avg_revenue_by_user_per_visit|\n|-----|-------------------------------|\n|201707|4.857            |\n\nIn July 2017, the average revenue generated per user per visit amounted to 43.857. This indicates that, on average, users spent around 44 during that time. Such a metric serves as a valuable tool for businesses to gauge user engagement and monitor overall activity levels.\n\n### **Query 07: Other products purchased by customers who purchased product \"YouTube Men's Vintage Henley\" in July 2017. Output should show product name and the quantity was ordered.**\n- SQL Code\n```sql\n\nWITH raw_data AS ( --find customer who purchased product \"YouTube Men's Vintage Henley\" in July 2017\n  SELECT \n    DISTINCT fullVisitorId\n    ,(product.v2ProductName) AS product_name1\n  FROM \n    `bigquery-public-data.google_analytics_sample.ga_sessions_201707*`,\n    UNNEST(hits) AS hits,\n    UNNEST(hits.product) AS product\n    WHERE\n      product.v2ProductName = \"YouTube Men's Vintage Henley\" AND product.productRevenue IS NOT NULL --Condition for fiding product name and purchasing\n)\nSELECT --Find the customer who purchased other products\n  product.v2ProductName\n  ,SUM(product.productQuantity) AS quantity --total_quantity\nFROM\n  raw_data rd\nLEFT JOIN \n  `bigquery-public-data.google_analytics_sample.ga_sessions_201707*`\nON  \n  rd.fullVisitorId = `bigquery-public-data.google_analytics_sample.ga_sessions_201707*`.fullVisitorId\n  ,UNNEST(hits) AS hits\n  ,UNNEST(hits.product) AS product\nWHERE product.v2ProductName \u003c\u003e \"YouTube Men's Vintage Henley\" AND product.productRevenue IS NOT NULL --condition for fiding customer who purchased other products\nGROUP BY\n  product.v2ProductName\nORDER BY  --sorting by quantity\n  quantity DESC;\n\n\n```\n|v2ProductName|quantity|\n|-------------|--------|\n|Google Sunglasses|20      |\n|Google Women's Vintage Hero Tee Black|7       |\n|SPF-15 Slim \u0026 Slender Lip Balm|6       |\n|Google Women's Short Sleeve Hero Tee Red Heather|4       |\n|YouTube Men's Fleece Hoodie Black|3       |\n|Google Men's Short Sleeve Badge Tee Charcoal|3       |\n|22 oz YouTube Bottle Infuser|2       |\n|Android Men's Vintage Henley|2       |\n|Google Men's Short Sleeve Hero Tee Charcoal|2       |\n|YouTube Twill Cap|2       |\n\nThe table highlights inventory levels, with Google Sunglasses having the highest quantity (20) and several items, like Google Lip Balm and YouTube Hoodies, having the lowest quantity (2). This snapshot is useful for managing stock or planning replenishment strategies.\n\n### **Query 08: Calculate cohort map from product view to addtocart to purchase in Jan, Feb and March 2017. For example, 100% product view then 40% add_to_cart and 10% purchase.Add_to_cart_rate = number product  add to cart/number product view. Purchase_rate = number product purchase/number product view. The output should be calculated in product level.**\n\n- Code SQL\n```sql\n\nWITH product_view AS( --find product view\n  SELECT\n    FORMAT_dATE(\"%Y%m\", PARSE_DATE(\"%Y%m%d\", date)) AS month\n    ,COUNT(product.productSKU) AS num_product_view\n  FROM \n    `bigquery-public-data.google_analytics_sample.ga_sessions_*`\n    ,UNNEST(hits) AS hits\n    ,UNNEST(hits.product) AS product\n  WHERE \n    _TABLE_SUFFIX BETWEEN '20170101' AND '20170331'\n    AND hits.eCommerceAction.action_type = '2'\n  GROUP BY \n    month\n),\n\nadd_to_cart AS(-- find add to cart\n  SELECT\n    FORMAT_DATE(\"%Y%m\", PARSE_DATE(\"%Y%m%d\", date)) AS month\n    ,COUNT(product.productSKU) AS num_addtocart\n  FROM \n    `bigquery-public-data.google_analytics_sample.ga_sessions_*`\n    ,UNNEST(hits) AS hits\n    ,UNNEST(hits.product) AS product\n  WHERE \n    _TABLE_SUFFIX BETWEEN '20170101' AND '20170331'\n    AND hits.eCommerceAction.action_type = '3'\n  GROUP BY \n    month\n),\n\npurchase as( --find purchase\n  SELECT\n    FORMAT_DATE(\"%Y%m\", PARSE_DATE(\"%Y%m%d\", date)) AS month\n    ,COUNT(product.productSKU) AS num_purchase\n  FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*`\n  ,UNNEST(hits) AS hits\n  ,UNNEST(hits.product) as product\n  WHERE \n    _TABLE_SUFFIX BETWEEN '20170101' AND '20170331'\n    AND hits.eCommerceAction.action_type = '6'\n    AND product.productRevenue IS NOT NULL   --must add this condition to ensure revenue\n  group by 1\n)\n\nSELECT\n  pv.*\n  ,num_addtocart\n  ,num_purchase\n  ,ROUND(num_addtocart*100/num_product_view,2) AS add_to_cart_rate --rate: add to cart\n  ,ROUND(num_purchase*100/num_product_view,2) AS purchase_rate --rate: purchase\nFROM \n  product_view pv\nLEFT JOIN \n  add_to_cart a\nON \n  pv.month = a.month\nLEFT JOIN\n  purchase p \nON \n  pv.month = p.month\nORDER BY --sorting by month\n  pv.month;\n\n```\n|month|num_product_view|num_addtocart|num_purchase|add_to_cart_rate|purchase_rate|\n|-----|----------------|-------------|------------|----------------|-------------|\n|201701|25787           |7342         |2143        |28.47           |8.31         |\n|201702|21489           |7360         |2060        |34.25           |9.59         |\n|201703|23549           |8782         |2977        |37.29           |12.64        |\n\nIn Q1 2017, engagement and conversion rates steadily increased, with March showing the highest rates—37.29% for add-to-cart actions and 12.64% for purchases—indicating enhanced user interest and activity.\n\n## 🔎V. Conclusion\n👉🏻 This project provide overview of eCommerce activity in website. Help manager grasp information about customer behavior. \\\n👉🏻 Analyzing the eCommerce dataset provided key insights into customer behavior, focusing on metrics such as bounce rate, transactions, revenue, visits, and purchases.\\\n👉🏻 The analysis of transactions and products provided valuable insights into customer purchasing behavior and product performance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheng23%2Fe-commerce-website-performance-analysis-sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheng23%2Fe-commerce-website-performance-analysis-sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheng23%2Fe-commerce-website-performance-analysis-sql/lists"}