How to export daily attribution model and assisted conversions data from Google Analytics

Get more insight from your multi-channel funnels and conversion paths data

Chris Bow
5 min readAug 2, 2018

Attribution modelling remains one of those slightly awkward marketing things. We’re perhaps not as stuck in the “Half the money I spend on advertising is wasted…” days, but most of us don’t exactly know which pound did what. However, more information is always helpful, and knowing which touchpoints led to a conversion can help us better optimise our campaigns and budgets. Enter Google Analytics’ Multi-Channel Funnels and Model Comparison Tool.

Multi-channel funnels and the model comparison tool

If you are familiar with Google Analytics, you probably already know what these are. In fact, probably the only reason you’ve read this far is that you’re already all too familiar with them and already know you can’t export the data in the same way you can for other reports.

If you don’t, then the take home messages are that concern us today are:

  • The multi channel funnels report can give you values for how your channels and campaigns ‘assisted’ through the journey to conversion
  • The model comparison tool can give you conversion values for your marketing channels and campaigns based on different attribution models such as first click and last click

Very useful, particularly if you have campaigns that you designed for prospecting and customer acquisition at the top of the funnel, and campaigns designed to encourage customers at the bottom of the funnel to convert. Using attribution models that dovetail with the goals of your campaigns can be valuable in helping you to calculate your return on investment and understand if your marketing activities are performing as they should against their goals.

The export market

Unfortunately, unlike many of the other reports in Google Analytics, you can’t export the data from these reports. If you want to combine these data with your other reports from Analytics or Google Ads, you’re going to have to do it manually: selecting your date range and copying the numbers into a spreadsheet.

Not a great way to work if you’ve got a couple of years’ worth of historic data you want to start including for a couple of dozen campaigns and you want to know the numbers at a daily level…

The MCF-API, R and RGA

A sub-heading of plenty letters there, but within them lies the path to export bliss. Using the open-source package R, the R package RGA and the API (Application Programming Interface) for Google Analytics’ Multi-Channel Funnels, thousands of rows of data can be on your desktop in seconds.

Even if you haven’t used R before, it’s quite a simple process to get set up and get your data from Analytics. It’s also free.

How to export attribution model and multi-channel funnels data from Google Analytics

The first thing to do is install the R software and RStudio IDE. You can download R for MacOS here, and for Windows here. With R installed, go ahead and download RStudio, a nicer to work with, more graphical environment that also helps you work with R and manage your files and projects.

With everything installed, open up RStudio. Click the icon with the ‘+’ on the green dot in the top left and select ‘R Script’.

Click on the disk icon to save your empty script and name it appropriately. Something like i_am_a_marketing_ninja seems about right.

There are a couple of things we need to install inside R before we can get to our reports. We need an add-on package called RGA to access the data and, to get the latest version of it, we need to use a package called devtools. To get those, paste this code into your script:

install.packages("devtools", dependencies=TRUE, repos='http://cran.rstudio.com/')library(devtools)install_github("artemklevtsov/RGA")library(RGA)

Click on the first line and click the icon labelled ‘Run’ at the top of the script. Run each line one at a time until you’ve done all four step. Okay, you’re ready to go.

The next thing you’ll need to do is give RGA permission to access your Analytics account, quickly done with this line:

authorize()

Run this line and this function should take you to your browser and bring up the familiar Google login box. Accept the request for access for the right account and return to R.

Important! This method uses the pre-installed API credentials for the RGA package. These are shared between everyone who uses RGA across the planet, and daily request numbers are limited. If you want to use this package regularly, you should set up your own API credentials and use those instead.

And with that, you’re ready to query. You’ll need your the id number for your reporting view. In the code below, I have assigned this to an object called profile_id, but you can just type yours in directly.

I have also assigned the start date and end dates to objects at the start of the query. You can just input these into the query directly but, if you are building multiple reports for the same dates in the same query, doing it this way means you only have to change them in one place the next time.

Here is the code for the running your query:

# Set report start and end datesstart_date <- "2018-07-01"
end_date <- "2018-07-31"
# Query MCF APImcf_data <- get_mcf(profileId = profile_id,
start.date = start_date, end.date = end_date,
metrics = "mcf:firstInteractionValue,
mcf:lastInteractionValue, mcf:assistedValue",
dimensions = "mcf:conversionDate, mcf:source, mcf:medium, mcf:campaignName",
sort = NULL,
filters = "mcf:medium == cpc",
samplingLevel = NULL,
start.index = NULL, max.results = NULL, fetch.by = NULL)

Run these chunks of code and await the magic.

Data returned from Google’s servers, you can then run the code head(mcf_data) to have a quick look at what has been returned. Hey, as you’re using RStudio, you can also see a bit more of your data using View(mcf_data).

Making your own reports and saving the data

Of course, chances are the metrics and dimensions might not be what you want for your own report. Not a problem: if you look in the code you’ll see metrics = and dimensions = sections. All you need to do is modify the parts inside the quotation marks to the ones you want, separated by commas. You can get the complete list of metrics and dimensions here, from the full MCF API reference guide.

If you don’t want to filter at this stage, simply change that part of the code from filters = "mcf:medium == cpc" to filters = NULL.

Now, you’re ready to save your output as a .csv file so you can import it to Excel and combine it with data you’ve exported from your other reporting platforms.

write.csv(mcf_data, "my_marketing_ninja_data.csv", row.names = FALSE)

Feel free to change the filename to something a little more humble, but you can still feel smug inside.

While you’re high on being a marketing insight unicorn though, you could always forget the export part and stay in R for your analytics, there are a lot of things it can do

Follow Chris on twitter

--

--

Chris Bow

Former immunologist turned data scientist and marketer. Proponent of applying scientific thinking to non-scientific problems. Consultant for Cairney & Company.