Last active
September 1, 2015 01:35
-
-
Save juangesino/62741ee63d0bb124612f to your computer and use it in GitHub Desktop.
EduData JavaScript Integration
This file contains 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
function buy(price) { | |
// Do your magic here | |
// And track the transaction here: | |
var token = "XXXXXXXXX" // Token found at EduData. | |
var tag = "TAG_NAME" // Give the tag a name. | |
var host = "HOST_NAME" // If using a backend server you can insert your hostname here. | |
var values = [parseInt(price)] // Array of values, in this case just the price of the item. | |
var unit = '$' // Set a unit for your measurement, you can leave an empty string. | |
var url = "http://data.edudata.com.ar/api/v1/measurements"; // EduData endpoint. | |
$.ajax({ | |
dataType: "json", | |
data: { token: token, tag: tag, values: values, unit: unit, host: host }, | |
type: "POST", | |
url: url, | |
success: function(data) { | |
// Handle success | |
}, | |
error: function(e) { | |
// Handle error | |
}, | |
timeout: function() { | |
// Handle timeout | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment