The following steps show how to make a scatterplot in Data Studio with the data from BigQuery:
- Update the original query by adding the transaction metric. In the edit screen of your report, click on the bar chart to bring up the chart options on the right-hand-side navigation. Click on the pencil icon next to the data source titled BigQuery to edit the data source.
- Click on the left-hand-side arrow icon titled Edit Connection:
- In the dialog titled Enter Custom Query, add this query:
SELECT trafficsource.medium as Medium,
COUNT(visitId) as Visits,
SUM(totals.transactions) AS Transactions
FROM `google.com:analytics-bigquery.LondonCycleHelmet.ga_sessions_20130910`
GROUP BY Medium
- Click on the button titled Reconnect in order to reprocess the query. A prompt should emerge, asking whether you'd like to add a new field titled Transactions. Click on Apply.
- Click on Done.
- Once you return to the report edit screen, click on the Scatter Chart button () and use your mouse to draw a square in the report space:
The report should autoselect the two metrics you've created.
- Click on the chart to bring up the chart edit screen on the right-hand-side navigation; then click on the Style tab.
- Click on the dropdown under the Trendline option and select Linear to add a linear trend line, also known as linear regression line. The graph will default to blue, so use the pencil icon on the right to select red as the line color:
You'll then be left with a scatterplot showing the correlation of visits to transactions for each medium in the BigQuery query data, as well as a regression line.