Sending custom events such as user or email data to Opentracker's events engine, can be done by using a simple javascript function.
Just (1) add the following snippet to the page where you collect the email value, and (2) replace the data in the javascript function.
<script>
// define an empty variable called 'map'
var map = new OTMap();
//define email variable to be send to Opentracker
map.put("email", "john.doe@example.com");
//send (submit) the data to Opentracker
OTLogService.sendEvent("email logged", map, false);
</script>
You will need to replace "john.doe@example.com" with the real data. This can be done in various ways with all types of programming languages.
Examples follow, please leave a comment if you have suggestions or improvements for this page.
Scenario: your target users land on a specific landing page, and you are able to append the email address or user id to the URL like this:
http://www.mysite.com/mypage.html?email=user@domain.com
Using various languages you can now grab this email address and pass the data to us.
Below are some examples of commonly used languages as javascript, PHP, JSP
<script type="text/javascript">
// jquery document ready
$(document).ready(function() {
// javascript function to get (multiple) variables from url
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return("");
}
// define an empty variable called 'map'
var map = new OTMap();
// grab the email from the url
var email = getQueryVariable("email");
//define email variable to be send to Opentracker
map.put("email", email);
//send (submit) the data to Opentracker
OTLogService.sendEvent("email logged", map, false);
});
</script>
use $_GET to parse the url variable to a php variable
<?php
/* grab the email from the url */
$email = $_GET["email"];
?>
Use the following javascript and populate the email value in the javascript
<script type="text/javascript">
// define an empty variable called 'map'
var map = new OTMap();
//define email variable to be send to Opentracker
map.put("email", "<?php echo $email ?>");
//send (submit) the data to Opentracker
OTLogService.sendEvent("email logged", map, false);
</script>
// grab the email from the url
String email = request.getParameter("email");
Use the following javascript and populate the email value in the javascript
<script type="text/javascript">
// define an empty variable called 'map'
var map = new OTMap();
//define email variable to be send to Opentracker
map.put("email", "<%= email %>");
//send (submit) the data to Opentracker
OTLogService.sendEvent("email logged", map, false);
</script>
Calling this function will update the event count in the cookie with +1 and update the timestamps, just like a normal page-view
would.
For some event types you may want to turn off this default functionality, which you can do by setting the last parameter to false.
OTLogService.sendEvent("some title", map, false);
For details on how to read Opentracker cookie data see here
We have pre-defined a number of event types, for example user-tagging, video, audio, download, print, etc. The list is growing . See the list of event types here