Created
September 20, 2019 18:56
-
-
Save cbarley10/8bcec506a678680b5c94be7add8ce38e to your computer and use it in GitHub Desktop.
test script for $event_id
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
const axios = require("axios"); | |
const Base64 = require('js-base64').Base64; | |
const endpoint = "https://a.klaviyo.com/api/track?data" | |
const object = JSON.stringify({ | |
token: [[ REDACTED ]], | |
event: "Louisiana Purchase", | |
customer_properties: { | |
$email: "thomas.jefferson@gmail.com" | |
}, | |
properties: { | |
$event_id: 10001235, | |
$value: 11250000, | |
From: "France", | |
SquareMiles: 828000 | |
}, | |
time: Math.floor(new Date().getTime() / 1000) | |
}); | |
const sendDataToKlaviyo = async obj => { | |
let base64obj = base64EncodeData(obj) | |
let response = await axios.get(`${endpoint}=${base64obj}`) | |
console.log(response.data) | |
} | |
const base64EncodeData = obj => Base64.encode(obj); | |
for (var i = 0; i < 20; i++) { | |
sendDataToKlaviyo(object) | |
console.log(i) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment