0

Possible (without writing complex scripts) to log gmail activity, primarily incoming email metadata (headers), send it to a Google Sheet or a bucket somewhere?

Reason I ask: want to run analytics on email headers including spam and other email that has been or is being routinely deleted. In my specific case, I just started receiving boatloads of spam to a specific gmail address (myemail+modifyer_of_some_sort@gmail.com) and before I clear it, wanted to log it for future analysis - just the headers.

E.g. "show me top sender's IP addresses for all email marked as spam in the last 30 (90, 10K) days".

Or, "show me top 'to' addresses for all email marked as spam in the last 30 days"

I don't believe there is a simple way to answer the above questions using gmail search - yet if I was able to continuously log the headers as KVs (JSON, XML, CSV, etc.) - then it'd be fairly simple.

I am assuming this isn't trivial - must dive deep into gmail API and write a script - but wanted to confirm in case anyone has done something similar.

Thanks!

2 Answers 2

1

You will want to use the Google Apps Script.

What is complex or not will depend on you. It is Javascript and there are a lot of resources for code snippets.

If you are clear on what you are trying to achieve and willing to search for solutions and ask the community it is totally doable.

It can be daunting at first but I wrote my first script recently and was not experienced in Javascript or App Scripts but I found the online resources for both plentiful. I really enjoyed the challenge and I'm sure you can get a ton of help from the community.

0

Gmail, as an email client for end users, doesn't include built-in analytics tools, they are offered only to Google Workspace administrators.

As a Gmail end-user you might use Google Apps Script and/or the Gmail API to read the data from your Gmail mailbox and log it to Google Sheets or to another data store to later use it to build your own analytics or use a third-party service.

Please bear in mind that there is no way to run a script / do a webhook call when a new message is received but it's possible schedule a collect data task every certain time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.