Skip to content

Instantly share code, notes, and snippets.

@theareba
Created May 10, 2018 13:29
Show Gist options
  • Save theareba/5a6535ef4641d6fe1dca452c4ee0a884 to your computer and use it in GitHub Desktop.
Save theareba/5a6535ef4641d6fe1dca452c4ee0a884 to your computer and use it in GitHub Desktop.
##### Email Opens:
### Event Test Endpoint:
https://ga-dev-tools.appspot.com/hit-builder/
### Creating GA query properties:
Unique Member ID, Message ID, Message Network & Message Content
From Admin > Custom Definitions > Custom Dimension(order sensitive), create these properties as dimensions(see article https://support.google.com/analytics/answer/2709829)
The resultant properties with the the keys: cd1, cd2, cd3 & cd4. These will be used in the event hit.
### Event Hit Summary Example:
POST /collect HTTP/1.1
Host: www.google-analytics.com
v=1&t=event&tid=UA-118875082-1&cid=23324&ec=email&ea=open&el=facebook%20credentials%20expiring%20for%20vicgoburg%40gmail.com&cd1=1&cd2=3&cd3=facebook&cd4=some%20message
### In rails:
@google_analytics_url = “http://www.google-analytics.com/collect?v=1&t=event&tid=UA-118875082-1&cid=#{@user.id}&ec=email&ea=open&el=#{ERB::Util.url_encode(‘credentials expiring’)}&cd1=#{@user.id}&cd2=#{}&cd3=#{authentication.platform_display_name}&cd4=#{}”
`N/B` All values sent to GA must be both UTF-8 & URL Encoded
### Embedding Analytics in Mailer:
<img src=<%= @google_analytics_url %>/>
##### Email Click Tracking:
Using utm parameters https://ga-dev-tools.appspot.com/campaign-url-builder/
Note: The email should have links back to your website or app. We recommend tagging the links with campaign parameters
### Postface
An update needs to be made to GaggleAMP-patrol https://github.com/GaggleAMP/Patrol/blob/master/lib/patrol/tracking_server.rb
to send hits/click tracks to GA.
@theareba
Copy link
Author

screen shot 2018-05-10 at 16 32 22

screen shot 2018-05-10 at 16 37 56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment