<?xml version="1.0" encoding="utf-8"?> 
<rss version="2.0">

<channel>

<title>LEFT JOIN: blog on analytics, visualisation &amp; data science, posts tagged: google analytics</title>
<link>https://en.leftjoin.ru/tags/google-analytics/</link>
<description></description>
<generator>E2 (v3386; Aegea)</generator>

<item>
<title>How to: Google App Script</title>
<guid isPermaLink="false">72</guid>
<link>https://en.leftjoin.ru/all/google-app-script/</link>
<comments>https://en.leftjoin.ru/all/google-app-script/</comments>
<description>
&lt;p&gt;Today’s post will shed some light on how you can use one of the very handy basic analytics tools – Google Sheets – even more effectively.&lt;br /&gt;
Often, analysts need to work a lot with tables and create selections for various conditions. In working with tables, the problem usually lies in the fact that you have to process and organize large amounts of data stored on different sheets. For example, you keep track of customers on one sheet of a spreadsheet, uploading data from third-party services, and you would like to add or change the data on another sheet. Let’s see how easy and simple we suggest to solve this problem.&lt;br /&gt;
&lt;img src="https://leftjoin.ru/pictures/1-2.jpg" border="0" width="100%" height="100%"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Script editor&lt;/h2&gt;
&lt;p&gt;If you have a Google account and data sheets uploaded to Google Sheets, then you can create a script for this table. Select the table in which you want to automate the transfer of information from one sheet to another, open it and select the “Script Editor” item from the “Tools” menu. The browser will redirect you to the Apps Script page, where you can create and edit scripts for the table.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://leftjoin.ru/pictures/--2021-11-10--16.20.29.png" border="0" width="100%" height="100%"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Automating line transfer to another sheet&lt;/h2&gt;
&lt;p&gt;So, our script should automatically perform the task of line transfer to another sheet. To do this, we create one more column in the table, in which it will be possible to check the box to transfer the line or remove it to cancel this action. Let’s see how exactly this is done.&lt;br /&gt;
When writing a script, you can use a trigger function that fires when a certain condition is met. You can read more about trigger functions &lt;a href="https://developers.google.com/apps-script/guides/triggers?hl=en#onedite"&gt;in the documentation&lt;/a&gt;. In our script, we use the OnEdit(e) function, which is triggered when a table cell is edited (toggle the checkbox on and off). We will call this function at the end of the script, but for now, we will write everything that should happen in the function.&lt;/p&gt;
&lt;pre class="e2-text-code"&gt;&lt;code&gt;function myScript(e) {   
  // We set the following condition for the function: you only need to react to clicking the checkmark in the eighth column on the &amp;quot;Лиды-воронка&amp;quot; sheet.
  if (e.source.getActiveSheet().getName() == &amp;quot;Лиды- воронка&amp;quot; &amp;amp;&amp;amp; e.range.getColumn() == 8)
  {
    // Saving the objects of the source sheet and the destination sheet
    destSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('test');
    sourceSheet = e.source.getActiveSheet();
    // We clear the destination sheet, starting from the second line, since we have a title in the table.
    destSheet.getRange(2, 1, destSheet.getLastRow(), destSheet.getLastColumn()).clearContent();
    // We go through all the cells with check marks, looking for those cells in which the check marks are put down.
    range = sourceSheet.getRange(1, 1, sourceSheet.getLastRow(), sourceSheet.getLastColumn());       
    for (i = 2; i &amp;lt;= range.getNumRows(); i++) 
    {      
      // We get all the checkboxes.
      if (range.getCell(i,8).getValue())
      {        
        // If the checkbox is filled, the current line is transferred to a new sheet.
        currentRow = sourceSheet.getRange(i, 1, i, sourceSheet.getLastColumn());           
        destSheet.appendRow(currentRow.getValues()[0]);
      }      
    }    
  }

// Then, we call a trigger function that will call our script every time we edit a cell.
function onEdit(e) {
  myScript(e)
}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;As a result, if a check mark in a column is selected, then the corresponding row will be transferred to another sheet. Also, it is important to remember that when you remove a check mark, the line is removed from another sheet.&lt;br /&gt;
In our example, we got the following two tables:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://leftjoin.ru/files/gas.gif" border="0" width="100%" height="100%"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Conclusions&lt;/h2&gt;
&lt;p&gt;Today we showed you an example of a script that will simplify, and maybe even improve, the routine work with tables. Of course, many more processes can be automated with Google Sheets scripts. You can read &lt;a href="https://developers.google.com/apps-script/overview?hl=ru"&gt;about other features&lt;/a&gt; yourself, and we’ll cover some of them in detail in future posts!&lt;/p&gt;
</description>
<pubDate>Wed, 10 Nov 2021 16:43:25 +0300</pubDate>
</item>

<item>
<title>Building a funnel-report in redash</title>
<guid isPermaLink="false">7</guid>
<link>https://en.leftjoin.ru/all/stroim-funnel-report-v-redash/</link>
<comments>https://en.leftjoin.ru/all/stroim-funnel-report-v-redash/</comments>
<description>
&lt;p&gt;So, we’ve been planning to review Funnel-visualization of a report in Redash.&lt;br /&gt;
First and foremost, let’s build a request &lt;a href="https://www.valiotti.com/leftjoin/all/how-to-connect-google-analytics-to-redash/"&gt;to the data source that we’ve created&lt;/a&gt; – Google Analytics.&lt;/p&gt;
&lt;p&gt;The following text needs to be placed in the request console:&lt;/p&gt;
&lt;pre class="e2-text-code"&gt;&lt;code&gt;{
    &amp;quot;ids&amp;quot;: &amp;quot;ga:128886640&amp;quot;,
    &amp;quot;start_date&amp;quot;: &amp;quot;30daysAgo&amp;quot;,
    &amp;quot;end_date&amp;quot;: &amp;quot;yesterday&amp;quot;,
    &amp;quot;metrics&amp;quot;: &amp;quot;ga:users,ga:goal1Completions,ga:goal2Completions,ga:goal3Completions&amp;quot;
}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In this request we are asking API Google Analytics to provide data for the last 30 days on the account GA: 128886640. We want to see the number of users and the number of completion of goals 1, 2 and 3.&lt;/p&gt;
&lt;p&gt;As a result, our table will look as follows:&lt;/p&gt;
&lt;div class="e2-text-table"&gt;
&lt;table cellpadding="0" cellspacing="0" border="0"&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;ga:users&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;b&gt;ga:goal1Completions&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;b&gt;ga:goal2Completions&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;b&gt;ga:goal3Completions&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3,926&lt;/td&gt;
&lt;td&gt;105&lt;/td&gt;
&lt;td&gt;41&lt;/td&gt;
&lt;td&gt;32&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;Great, that’s right what we need in order to build a funnel.&lt;br /&gt;
Now I will tell you about one very useful Redash feature: &lt;i&gt;query-results&lt;/i&gt;. In order to connect tables with results of queries’ execution, we go to &lt;i&gt;Data Sources&lt;/i&gt; and search for &lt;i&gt;query-results (beta)&lt;/i&gt;. Connecting new data source.&lt;br /&gt;
Now we have an opportunity to refer to results of Redash queries. Thus, for instance, we can use the results of a requests to Google Analytics API.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;How to do it?&lt;/b&gt;&lt;br /&gt;
We need to choose a data source query-results on the left:&lt;/p&gt;
&lt;div class="e2-text-picture"&gt;
&lt;img src="https://en.leftjoin.ru/pictures/query-results.png" width="350" height="78" alt="" /&gt;
&lt;div class="e2-text-caption"&gt;Drop down menu with selection of data sources (in the console – on the left)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Now we’ll learn to make funnel-visualization. For this purpose, we write the following SQL-query:&lt;/p&gt;
&lt;pre class="e2-text-code"&gt;&lt;code&gt;select 'Add a good to the shopping cart' as step_name, ga_goal1Completions as goalCompletion from query_8
union all
select 'View the shopping cart' as step_name, ga_goal2Completions from query_8
union all
select 'Order processing' as step_name, ga_goal3Completions from query_8&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In this case &lt;i&gt;query_8&lt;/i&gt; – is the very table with results of request to the data source Google Analytics.&lt;/p&gt;
&lt;p&gt;Let’s set visualization:&lt;/p&gt;
&lt;div class="e2-text-picture"&gt;
&lt;img src="https://en.leftjoin.ru/pictures/visualisation.png" width="600" height="513" alt="" /&gt;
&lt;div class="e2-text-caption"&gt;Carefully selecting parameters, in order to achieve the desired result&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;As a result, we receive the funnel of conversions from one goal to another:&lt;/p&gt;
&lt;div class="e2-text-picture"&gt;
&lt;img src="https://en.leftjoin.ru/pictures/funnel.png" width="600" height="152" alt="" /&gt;
&lt;div class="e2-text-caption"&gt;You can display this funnel in the dashboard and add filters / parameters thereto.&lt;/div&gt;
&lt;/div&gt;
</description>
<pubDate>Tue, 04 Dec 2018 14:36:00 +0300</pubDate>
</item>

<item>
<title>How to connect Google Analytics to Redash?</title>
<guid isPermaLink="false">4</guid>
<link>https://en.leftjoin.ru/all/how-to-connect-google-analytics-to-redash/</link>
<comments>https://en.leftjoin.ru/all/how-to-connect-google-analytics-to-redash/</comments>
<description>
&lt;p&gt;In this article we will take a look at how to connect the data source Google Analytic to the service &lt;a href="http://redash.io/"&gt;Redash&lt;/a&gt; [We have already examined Redash and its opportunities more thoroughly &lt;a href="http://leftjoin.ru/all/redash-polnocennaya-on-demand-analitika/"&gt;in the previous notes&lt;/a&gt;].&lt;/p&gt;
&lt;h2&gt;Creating service account in Google&lt;/h2&gt;
&lt;p&gt;Moving to &lt;a href="https://console.cloud.google.com/projectselector/iam-admin/serviceaccounts?supportedpurview=project&amp;project=&amp;folder=&amp;organizationId="&gt;console of service accounts&lt;/a&gt;.&lt;/p&gt;
&lt;div class="e2-text-picture"&gt;
&lt;img src="https://en.leftjoin.ru/pictures/2018-11-13_18-57-05.png" width="550" height="234" alt="" /&gt;
&lt;div class="e2-text-caption"&gt;Creating new service account&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In the window of account creating we insert the name, forming a new key afterwards. We select that we need JSON key and then press “Create”.&lt;/p&gt;
&lt;h2&gt;Integrating Analytics API&lt;/h2&gt;
&lt;p&gt;For the service account we’ve created, we need to integrate Analytics API.&lt;/p&gt;
&lt;div class="e2-text-picture"&gt;
&lt;img src="https://en.leftjoin.ru/pictures/2018-11-14_18-51-02.png" width="450" height="136" alt="" /&gt;
&lt;div class="e2-text-caption"&gt;When we’ve set everything up, Analytics API should be of green colour&lt;/div&gt;
&lt;/div&gt;
&lt;h2&gt;Adding service user to Google Analytics&lt;/h2&gt;
&lt;p&gt;Next, we need to create the service user we’ve created to Google Analytics. The user will look approximately as follows:&lt;br /&gt;
user@PROJECT-ID.iam.gserviceaccount.com.&lt;br /&gt;
It is necessary &lt;a href="https://support.google.com/analytics/answer/1009702"&gt;to add the user&lt;/a&gt; with rights to Reading and View.&lt;/p&gt;
&lt;h2&gt;Creating new data source in Redash&lt;/h2&gt;
&lt;p&gt;Moving to settings (Settings) -&gt; Adding new data source&lt;/p&gt;
&lt;div class="e2-text-picture"&gt;
&lt;img src="https://en.leftjoin.ru/pictures/2018-11-13_18-53-19_2.png" width="500" height="230" alt="" /&gt;
&lt;div class="e2-text-caption"&gt;Connecting new data source.&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;We are interested in data source Google Analytics, therefore we search “google”:&lt;/p&gt;
&lt;div class="e2-text-picture"&gt;
&lt;img src="https://en.leftjoin.ru/pictures/2018-11-13_18-54-21_2.png" width="450" height="204" alt="" /&gt;
&lt;div class="e2-text-caption"&gt;Searching google analytics in data sources.&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Let’s recall where we’ve saved JSON file, we are going to need it now&lt;/p&gt;
&lt;div class="e2-text-picture"&gt;
&lt;img src="https://en.leftjoin.ru/pictures/new.png" width="500" height="330" alt="" /&gt;
&lt;div class="e2-text-caption"&gt;Selecting the JSON file created before&lt;/div&gt;
&lt;/div&gt;
&lt;h2&gt;Writing a query to the new data source&lt;/h2&gt;
&lt;p&gt;The query in Redash looks as follows:&lt;/p&gt;
&lt;pre class="e2-text-code"&gt;&lt;code&gt;{
    &amp;quot;ids&amp;quot;: &amp;quot;ga:128886640&amp;quot;,
    &amp;quot;start_date&amp;quot;: &amp;quot;30daysAgo&amp;quot;,
    &amp;quot;end_date&amp;quot;: &amp;quot;yesterday&amp;quot;,
    &amp;quot;metrics&amp;quot;: &amp;quot;ga:users,ga:newUsers,ga:goal1Starts,ga:goal2Completions,ga:goal3Starts,ga:transactions,ga:transactionRevenue&amp;quot;, 
    &amp;quot;dimensions&amp;quot;: &amp;quot;ga:date&amp;quot;
}&lt;/code&gt;&lt;/pre&gt;&lt;h2&gt;How to know parameters for query execution?&lt;/h2&gt;
&lt;p&gt;Google has a great resource &lt;a href="https://ga-dev-tools.appspot.com/query-explorer/"&gt;Query Explorer&lt;/a&gt;, in which one can find all the required metrics and measurements, that are available in Google Analytics.&lt;/p&gt;
&lt;p&gt;I hope, this instruction was useful for you, further on we will find out how to make a goals funnel in Redash, basing on the data from Google Analytics.&lt;/p&gt;
</description>
<pubDate>Tue, 27 Nov 2018 14:07:07 +0300</pubDate>
</item>


</channel>
</rss>