Our own goal was to simply track the increase and decrease in the viewing of emails sent from the website. We wanted to be able to see if changes to our email format affected email delivery. Since most email clients make the user enable images to be loaded in HTML emails, you won’t get true statistics on views, but over time you’ll definitely be able to notice increases and decreases in email viewing.
Below is our altered function that we call in order to create the URL needed to be placed in the image source. We wanted to only record the type of email that was viewed, not any URL/Referrer information like GA normally records. So we altered the function to remove the URL/Referrer code and to accept an $emailcampaign parameter which we populate with “email-something”.
$GA_ACCOUNT = “UA-XXXXX-1″;
$GA_PIXEL = “_ga.php”;
global $GA_ACCOUNT, $GA_PIXEL;
$url = “”;
$url .= $GA_PIXEL . “?”;
$url .= “utmac=” . $GA_ACCOUNT;
$url .= “&utmn=” . rand(0, 0x7fffffff);
$path = $emailcampaign;
$url .= “&utmp=” . urlencode($path);
$url .= “&guid=ON”;
While we create the HTML string for the email we call googleAnalyticsGetImageUrl(“email-something”) and set the result as the “src” of an image tag placed at the end of the body of our HTML email. Then in GA we can search for Content like “email-” and see all of the views based on the type of email (campaign).