Ad Engagement Event

Example data model for an ad engagement.

by Stephane Nouvellon

HTML

<script src="https://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.1.3.min.js"></script>
<div id='yeah'>
Practice writing/modifying a custom event. To send data to your own Keen project, create a free Keen account (https://keen.io) and change the projectID and writeKey to match your account. Press Run to send your event to Keen.
</div>

JavaScript

var client = new Keen({
	projectId: 'fff',
	writeKey: '74D67280C9A4FC2A4CF200D05809A458A814DA683EF5EDE12C3F1FA8838E9B39E4EC6F9AE65CACBABF17C2061B5EE7D17F9E43CBFD2ADDE794A1AF148D4C1B1478897D874E1E7AF08AB2725650485DAE3D3004E6722F4E54EA13935AA83E68F5'
});

var eventA = { 
  ad_interaction_type: "spin_carousel", // define arbitrary properties and values
  ad : {
    campaign: "Intelligent-Apps-Geo_US", // properties can be nested!
    content: "Intelligent-Apps-Images-Carousel-A",
    id: "7783",
    client: "923" 
  },
  article : {
    author: "Adelaide Wild",
    category: "Technology",
    url: document.URL
  },
  ip_address: "${keen.ip}",  // this value tells Keen to grab the request IP address
    keen: {
    addons: [{ // optional addons take data like IP or Agent and add new properties
      name: "keen:ip_to_geo",
      input: {
        ip: "ip_address"
      },
     output: "ip_geo_info"
    }]
  }
}

// Record the event (send it to Keen IO)
client.recordEvent('my_custom_ad_engagements3', eventA, function(err, res){
	if (err) {
		document.getElementById('yeah').innerHTML = "Something is amiss. Check console for errors. Did you forget a comma perhaps? Or a curly brace?"
	}
	else {
    document.getElementById('yeah').innerHTML = "You just sent an event to Keen IO!"
	}
});