Hey there!
I’m Benjamin from Loves Data and in this video I’m going to show you how you can
use the Google Analytics User Deletion API, along with Google Sheets to delete user data
from Google Analytics.
You might be wondering – ‘Why would I want to delete user data from Google Analytics?’
Well, in most cases you’ll only ever need to delete data like this because of a request
under the GDPR.
And if you’re not familiar with the GDPR (or General Data Protection Regulation), then
watch my video that explains the regulation and the most important things to know about
the GDPR and Google Analytics.
Now let’s head to Google Sheets and look at how we can use the User Deletion API to
delete data from Google Analytics…
This is Loves Data’s user deletion tool…
It’s built in Google Sheets and uses the Google Analytics User Deletion API to delete
user data from Google Analytics.
We’ve made it really easy to use.
At the top of the sheet we can enter the Google Analytics Property ID…
This is property where the data will be deleted.
Then there is a cell where you can enter the ‘client ID’ or the ‘user ID’ for the
data you want to delete…
Once you’ve entered a client ID or user ID, you’ll then need to select the type
from the drop-down…
You can choose from ‘client ID’ or ‘user ID’.
Then you just need to click the button when you’re ready to delete the data…
We’ll need to authorize the script to work, so let’s select ‘Tools’...
And then ‘Script Editor’...
This shows us the script that sends the deletion request to the Google Analytics User Deletion
API.
The top of the script pulls the details from the spreadsheet…
And then we can see the scripts constructs the API call…
It includes the type of ID and then the particular ID to delete from Google Analytics…
It then sends the request to the API…
And finally the script adds details to the sheet for the data that has been deleted.
To authorize the script to use the Google Analytics API, so we select ‘Resources’...
And then ‘Advanced Google Services’...
Then we need to ensure that the Google Analytics API is set to ‘On’...
We can see it’s already on, so that’s great.
Now we need to select ‘Google API Console’...
And select the option to enable APIs…
We search for ‘Google Analytics’...
And select ‘Analytics API’...
Then we need to enable the API…
Now let’s head to Google Analytics….
I’m in the ‘User Explorer’ report…
And I’m going to search for a Client ID for my last visit to my website…
I can see my Client ID, so now I’m going to head to Google Sheets to delete my user
data from Google Analytics…
Now I enter the Client ID into the Loves Data User Deletion Tool…
I ensure Client ID is selected…
And now I click the ‘delete data’ button…
I need to authorize the script...
I click ‘continue’...
And then ‘allow’...
I can now see that the data has been deleted.
Now let’s head back to Google Analytics…
I can still see the client ID in the ‘User Explorer’ report, but let’s click on the
ID…
We can now see that Google Analytics is deleting my user data.
So all of my data will be deleted within 72 hours.
That’s it!
We’ve deleted data from Google Analytics!
So that’s how you can use Google Sheets along with the Google Analytics User Deletion
API to delete user data from Google Analytics.
Remember, that once you’ve deleted the data for a user, that’s it, there’s no ‘undo’,
so make sure you’re certain you want it deleted.
I recommend creating a testing property for testing, before applying our solution to your
primary Google Analytics property.
You’ll find a link go get a copy of the spreadsheet, the script and extra resources
in the description below this video.
Have you ever needed to delete user data from Google Analytics?
I’d love to know!
Let me know in the comments below.
And if you found this video helpful, then please like it, so I know to make more videos
like this one.
See you next time!