{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"markdown","source":"# Kaggle Google Analytics: Feature engineering - Analysis and EDA on Tableau\n\nThis notebook digs deeper into the GA data and features and attempts to extract insights by applying various ratios to subsets and categorical variables. This is currently work in progress and any comments, ideas or suggestions are welcome\n\n# Introduction and context\ntbc\nPaper to be discussed: https://arxiv.org/pdf/1701.07852.pdf\nError analysis for context: https://www.kaggle.com/xavierbourretsicotte/lgbm-error-analysis-eda-and-thoughts\n\n## Description and intuition behind the main variables\n\n### Categorical variables\n\n- **source**: the *origin* of website traffic. Possible sources include: “google” (the name of a search engine), “facebook.com” (the name of a referring site), “spring_newsletter” (the name of one of your newsletters), and “direct” (users that typed your URL directly into their browser, or who had bookmarked your site).\n- **Medium**: the *category* of the traffic source. Possible medium include: “organic” (unpaid search), “cpc” (cost per click, i.e. paid search), “referral” (referral), “email” (the name of a custom medium you have created), “none” (direct traffic has a medium of “none”).\n- **channel**: a group of several traffic sources with the same medium\n- **channelGrouping**: a *set of channels* which can help more easily highlight or aggregate traffic channels. \n- **Keyword**: When SSL search is employed, Keyword will have the value (not provided).\n- **Campaign** is the name of the referring Google Ads campaign or a custom campaign that you have created.\n- **Content** identifies a specific link or content item in a custom campaign. For example, if you have two call-to-action links within the same email message, you can use different Content values to differentiate them so that you can tell which version is most effective.\n- **geoNetwork.networkDomain**: The domain name of user's ISP, derived from the domain name registered to the ISP's IP address.\n- **trafficSource.adwordsClickInfo.gclId**: Google click ID\n- **trafficSource.adwordsClickInfo.page**: Page number in search results where the ad was shown.\n- **trafficSource.adwordsClickInfo.slot**: Position of the Ad. Takes one of the following values:{“RHS\", \"Top\"}\n- **referralPath**: If trafficSource.medium is \"referral\", then this is set to the path of the referrer. (The host name of the referrer is in trafficSource.source.)\n\n### Numerical\n- **visitnumber**: The session number for this user. If this is the first session, then this is set to 1. \n- **bounces**: tbc\n- **hits**: tbc\n- **newVisits**: If this is the first visit, this value is 1, otherwise it is null.\n- **pageviews**: Total number of pageviews within the session.\n\nGA descriptions are: https://support.google.com/analytics/answer/1033173?hl=en&ref_topic=6010089\n"},{"metadata":{"_uuid":"254e4064004e107a65cf12b5cbd8061f97b86ed3"},"cell_type":"markdown","source":"# A summary of features and ratios for the main variables\nThe following story brings shows the relationship between the 5 features (columns) and the 3 main prediction proxys (rows) when applied to different views, slices and variables of the dataset. \n\nFor example, how does the bounce rate impact the average revenue per session, when analysed at the level of referral paths. In other words, do referral paths with a high bounce rate have low revenue per session ? (yes) \n\n### Features: \n- Bounce rate\n- Hits per session\n- Page views per session\n- Hits per pageviews\n- Average visit number\n- Average time since last visit. \n\n### Prediction proxys\nThere are three different ways of looking at the final prediction, each with their own benefits and drawbacks. Note that each of these are calculated at the appropriate level of granularity\n- Revenues per session: this is the prediction target used by models at the *session level* \n- Percentage of session with positive revenues (i.e. non zero): this can be viewed as the target of a classification model at the *session level* \n- Total revenues: calculated at the corresponding level of granularity \n\n### Levels of granularity\n- Country\n- Country + city\n- Referral path\n- Keyword\n- Source\n- Medium + city\n- Network Domain\n- Network Domain + city\n\n### Regression line\nA simple linear regression line is fitted to each graph, the *p-value* can be seen by hovering your mouse above the line. This can be useful to gain intuition, but an alternative way of viewing the potential impact of the feature is to look for vertical lines, or cuts in the data, which are well modeled by decision trees. More discussion tbc \n"},{"metadata":{"trusted":true,"_uuid":"6263725bc3010472844ff99473eeeff24805f74c","_kg_hide-input":true},"cell_type":"code","source":"%%HTML\n<div class='tableauPlaceholder' id='viz1538638609624' style='position: relative'><noscript><a href='#'><img alt=' ' src='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;2N&#47;2N75FGWFZ&#47;1_rss.png' style='border: none' /></a></noscript><object class='tableauViz'  style='display:none;'><param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' /> <param name='embed_code_version' value='3' /> <param name='path' value='shared&#47;2N75FGWFZ' /> <param name='toolbar' value='yes' /><param name='static_image' value='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;2N&#47;2N75FGWFZ&#47;1.png' /> <param name='animate_transition' value='yes' /><param name='display_static_image' value='yes' /><param name='display_spinner' value='yes' /><param name='display_overlay' value='yes' /><param name='display_count' value='yes' /><param name='filter' value='publish=yes' /></object></div>                <script type='text/javascript'>                    var divElement = document.getElementById('viz1538638609624');                    var vizElement = divElement.getElementsByTagName('object')[0];                    vizElement.style.width='1016px';vizElement.style.height='1014px';                    var scriptElement = document.createElement('script');                    scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js';                    vizElement.parentNode.insertBefore(scriptElement, vizElement);                </script>","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"5415b7f4f299aeeff24b81f9cdf74228ebf6c29a"},"cell_type":"markdown","source":"# Map\n\n### Average bounce rates (colors) and revenue per session (size of black dot) "},{"metadata":{"trusted":true,"scrolled":false,"_uuid":"e57c0bb3eac260444d55b4f6b0a4ed4d531583cb"},"cell_type":"code","source":"%%HTML\n<div class='tableauPlaceholder' id='viz1538639356356' style='position: relative'><noscript><a href='#'><img alt=' ' src='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;Ka&#47;KaggleGoogleAnalytics-Featureandratios&#47;Map1&#47;1_rss.png' style='border: none' /></a></noscript><object class='tableauViz'  style='display:none;'><param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' /> <param name='embed_code_version' value='3' /> <param name='site_root' value='' /><param name='name' value='KaggleGoogleAnalytics-Featureandratios&#47;Map1' /><param name='tabs' value='yes' /><param name='toolbar' value='yes' /><param name='static_image' value='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;Ka&#47;KaggleGoogleAnalytics-Featureandratios&#47;Map1&#47;1.png' /> <param name='animate_transition' value='yes' /><param name='display_static_image' value='yes' /><param name='display_spinner' value='yes' /><param name='display_overlay' value='yes' /><param name='display_count' value='yes' /><param name='filter' value='publish=yes' /></object></div>                <script type='text/javascript'>                    var divElement = document.getElementById('viz1538639356356');                    var vizElement = divElement.getElementsByTagName('object')[0];                    vizElement.style.width='100%';vizElement.style.height=(divElement.offsetWidth*0.75)+'px';                    var scriptElement = document.createElement('script');                    scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js';                    vizElement.parentNode.insertBefore(scriptElement, vizElement);                </script>","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"5d3d4803218c7e672335702fc2f12a29e62bfd5f"},"cell_type":"markdown","source":"# Investigating traffic quality\n*Are there any bots ?*\n\nNote that when the hit per session ratio is **exactly** 1, 2 or 3, absolutely no sessions have any revenues. A similar effect applies to hits per page when the ratio is exactly 2, 3 or or 4. A possible explanation is that bots, crawlers or other automated scripts may be the only ones that on average, behave in sch a way... \n"},{"metadata":{"trusted":true,"_uuid":"49b6d03323c71740626eeccb149c43cd6f5e0206","_kg_hide-input":true},"cell_type":"code","source":"%%HTML\n<div class='tableauPlaceholder' id='viz1538639607639' style='position: relative'><noscript><a href='#'><img alt=' ' src='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;Ka&#47;KaggleGoogleAnalytics-Featureandratios&#47;NetworkDomain_hits_per_sess_1&#47;1_rss.png' style='border: none' /></a></noscript><object class='tableauViz'  style='display:none;'><param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' /> <param name='embed_code_version' value='3' /> <param name='site_root' value='' /><param name='name' value='KaggleGoogleAnalytics-Featureandratios&#47;NetworkDomain_hits_per_sess_1' /><param name='tabs' value='yes' /><param name='toolbar' value='yes' /><param name='static_image' value='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;Ka&#47;KaggleGoogleAnalytics-Featureandratios&#47;NetworkDomain_hits_per_sess_1&#47;1.png' /> <param name='animate_transition' value='yes' /><param name='display_static_image' value='yes' /><param name='display_spinner' value='yes' /><param name='display_overlay' value='yes' /><param name='display_count' value='yes' /><param name='filter' value='publish=yes' /></object></div>                <script type='text/javascript'>                    var divElement = document.getElementById('viz1538639607639');                    var vizElement = divElement.getElementsByTagName('object')[0];                    vizElement.style.width='100%';vizElement.style.height=(divElement.offsetWidth*0.75)+'px';                    var scriptElement = document.createElement('script');                    scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js';                    vizElement.parentNode.insertBefore(scriptElement, vizElement);                </script>","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"54155c1b8fb6c30a0c7d0d631dbf4da927508658"},"cell_type":"markdown","source":"# Next steps..."},{"metadata":{"_uuid":"4d5a9748fe16ef42db003ce3345f1f303c034887"},"cell_type":"markdown","source":"..."},{"metadata":{"trusted":true,"_uuid":"5a332bd36373bc4cc3f41dee17daa0294cd20946"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"411b176483e3ca4ee0df41ef7fc62336c02878c0"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}