Created
January 22, 2013 23:01
-
-
Save joshed-io/4599555 to your computer and use it in GitHub Desktop.
Send an event to keen.io via a GET request, useful for placing image beacons.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Send an event to keen.io via a GET request | |
| # Useful for placing image beacons in email | |
| # (Traditional POST approach is still recommended where possible) | |
| require 'json' | |
| require 'base64' | |
| # Get a project ID and API Key from keen.io | |
| project_id = "your-project-id" | |
| api_key = "your-api-key" | |
| event_collection = "email_opens" | |
| data = { | |
| :recipient => "art@vandelay.com", | |
| :ab_test_choice => "A" | |
| } | |
| encoded_data = Base64.urlsafe_encode64(JSON.dump(data)) | |
| url = "https://api.keen.io/3.0/projects/#{project_id}/events/#{event_collection}?api_key=#{api_key}&data=#{encoded_data}" | |
| puts "Here's the URL:\n\n" | |
| puts url |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To log an event when a user opens an email, place an image tag in the email with the 'src' attribute pointing to the URL like the one we just created.
When the user opens the email (and chooses to view images), the event will be published to Keen IO.
The call returns a 1x1 transparent GIF, so the presentation of your email will not be altered, nor should you see any warnings when debugging in a console.