Store & Manage your email newsletter list using Google Analytics

In Analytics, SEO, The Digital Marketing Blog by John4 Comments

This is a little Google Analytics hack I came up with the other day. Its not exactly a ‘robust’ solution but it might be useful for somebody!

The idea is to turn Analytics into a database for your email newsletter subscription list (or any other form where you want to collect a basic list of email addresses) .

Usually this will be done in one of three ways:

1. Integrate your web form with your CRM system– the best solution but can be tricky/ expensive to setup
2. Store the emails in a web based database then export them later – simple but requires a database and some sort of server side coding i.e. PHP
3. Send an email to yourself with the addresses each time someone signs up- pretty easy using CGI’s but can be a real pain to manage if you have a lot of subscribers.

With this hack all you need is a few lines of javascript and a Google Analytics account- simples:-)

PS- The javascript part of this I borrowed from Joe Burns tutorial on javascript url variable passing. If you can’t follow my notes below that tutorial might help.

OK, here’s how to do it-

Setup your form:

You can see a demo of this here

The basic code you want is below, all this form needs to do is link to a free text form field to a page called ‘subscribe.html’.

Notice that the form uses METHOD=”LINK” where as you would usually use METHOD=”POST” for this kind of form. The javascript we’re using on the next page won’t understand the POST so make sure you use LINK.

I’ve also added some basic javascript form validation so you have to enter a properly formatted email address. This type of validation isn’t ideal but because we’re not using any PHP/ .asp on the next page its the only way to validate. If you’re using this script this shouldn’t be a problem though.

<title>Subscribe to the newsletter</title>
<script type="text/javascript">function validate_email(field,alerttxt)


with (field)




if (apos<1||dotpos-apos<2)

{alert(alerttxt);return false;}

else {return true;}


}function validate_form(thisform)


with (thisform)


if (validate_email(email,"Not a valid e-mail address!")==false)

{email.focus();return false;}






<h2>Subscribe to our newsletter</h2>

<FORM METHOD="LINK" ACTION="subscribe.html" onsubmit="return validate_form(this)">Email address:

<INPUT NAME="email" TYPE="text" id="email">
<INPUT TYPE="submit" VALUE="Subscribe!"> </FORM>

Setup your thank you page

Next you need to create a page called subscribe.html. This page will post a variable into the address bar with the email address you submit on the previous page, which will allow us to save the address in Google Analytics.


Here’s the code you need on this page. Obviously you can change the thank you message to say whatever you want and you’ll want to use your own Google Analytics tracking code, not ours!

<FORM NAME="joe"><INPUT TYPE="hidden" NAME="burns" SIZE="35"></FORM>

<SCRIPT LANGUAGE="javascript">

var locate = window.location

document.joe.burns.value = locate

var text = document.joe.burns.value

function delineate(str){

theleft = str.indexOf("=") + 1;

theright = str.lastIndexOf("&");

return(str.substring(theleft, theright));


document.write("Thanks for subscribing to the newsletter ");


<SCRIPT LANGUAGE="javascript">

var locate = window.location

document.joe.burns.value = locate

var text = document.joe.burns.value

function delineate2(str){

point = str.lastIndexOf("=");



document.write("We've added your email address to the list");


<script src="" type="text/javascript">


<script type="text/javascript">

_uacct = "UA-XXXXXX-X";



Capture the email addresses with Google Analytics

OK so we’ve sent Google Analytics a pageview with the email address in the url so if you login to Analytics, go to ‘Content’ and ‘top content’ and filter the page name ‘subscribe.html’ you should see a list of the pages with the email addresses in the variables like you see below:


You could extract this data and remove the email addresses but to make this really simple we’re going to use Google Analytics site search tracking to filter out the addresses from the page names.

If you’re already using Google Analytics site search tracking you’ll want to setup a new profile for tracking your emails.

Configuring site search to capture the emails

This is easy. Just go to your Analytics profile settings and  enable site search. Then put ’email’ in the ‘query parameters’ box.


Viewing your subscribers

Now you just need to go to your Site search report and look at ‘search terms’ and you should have a nice clean list of email subscribers. When you want to send out an email just export the search terms report as a CSV file and there’s your list!


When to use this script

I haven’t used this on any live sites and theoretically its open to abuse but if you want a really simple email signup on a site with no database this might help.

Related Posts Plugin for WordPress, Blogger...


  1. Very clever hack! Would be pretty easy to extend it to manage unsubscribes too.

    And you could segment the list based on other data in analytics?

  2. Easiest thing with unsubscribes will probably be to add an unsubscribe link in your emails like-

    …/unsubscribe.html? then remove the unsubscribes from the subscriber list in excel. Might be a more clever way but can’t think of it at the mo!

    You would then be able to use GA segments to work out how your subscribers found the site, what page they subscribed on that sort of thing.

  3. Pingback: サンキューページに仕掛けるサイト内検索hack | カグア!Google Analytics 活用塾:事例や使い方

  4. Pingback: サンキューページに仕掛けるサイト内検索hack | カグア!Google Analytics 活用塾:事例や使い方

Leave a Comment