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
| <script type="text/javascript"> | |
| var item = { | |
| "$value": item.Price, | |
| "ProductName": item.ProductName, | |
| "ProductID": item.ProductID, | |
| "SKU": item.SKU, | |
| "Categories": item.Categories, | |
| "ImageURL": item.ImageURL, | |
| "URL": item.URL, |
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
| var request = require("request") | |
| var options = { | |
| method: 'POST', | |
| url: 'https://a.klaviyo.com/api/track', | |
| headers: { | |
| accept: 'text/html', | |
| 'content-type': 'application/x-www-form-urlencoded' | |
| }, | |
| form: { |
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
| #imports | |
| from urllib.request import urlopen | |
| import json | |
| # variables | |
| json_list = [] | |
| json_keys = {} | |
| # 1. Open and serialize text file | |
| text = open("data.txt", "r") |
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
| import requests | |
| url = "https://a.klaviyo.com/api/v1/metric/METRIC_ID/timeline" | |
| querystring = {"api_key":"PRIVATE_KEY","page":"0","count":"100"} | |
| headers = {"Accept": "application/json"} | |
| response = requests.request("GET", url, headers=headers, params=querystring) | |
| data_frame = pandas.DataFrame(response.data) | |
| data_frame.to_csv("~/CSV_LOCATION/CSV_NAME.csv") |
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
| if (Array.isArray(klaviyoCookie) && klaviyoCookie.length && localStorageAvailable()) { | |
| klaviyoCookieData = JSON.parse(atob(klaviyoCookie[0].split("__kla_id=")[1])) | |
| function klPushFromLocal(identifierKey, identifierValue) { | |
| anonBackfillDebugLogger("| Pushing track and identify requests from local storage to Klaviyo...") | |
| // run through all local identify & track requests and send to klaviyo | |
| var klRequest = []; | |
| var klResponse = ""; | |
| var localKlaviyo = JSON.parse(localStorage.getItem("localKlaviyo")) || []; | |
| while (localKlaviyo.length > 0) { |
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
| if (!klaviyo.isIdentified()) { | |
| // If the cookie doesn't contain an exchange ID, override the the push functionality for the klaviyo sdk | |
| klaviyo.old_push = klaviyo.push | |
| klaviyo.push = function (request) { | |
| if (request[0] === "identify") { | |
| // if someone attempts to identify the email address, unoverride push | |
| if (Object.keys(request[1]).includes("$email")) { | |
| klaviyo.push = klaviyo.old_push | |
| klaviyo.push(["identify", { $email: request[1]["$email"] }]) | |
| // then push everything in localstorage as a raw request |
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
| function klLocalIdentify(klPropertyPayload) { | |
| // process and store a local identify request | |
| var localKlaviyo = JSON.parse(localStorage.getItem("localKlaviyo")) || []; | |
| var payload = { | |
| token: PUBLIC_API_TOKEN, | |
| properties: klPropertyPayload, | |
| }; | |
| if (localKlaviyo.length == klQueuedRequestLimit) { | |
| localKlaviyo.pop(); |
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
| if (!klaviyo.isIdentified()) { | |
| // If the cookie doesn't contain an exchange ID, override the the push functionality for the klaviyo SDK | |
| klaviyo.old_push = klaviyo.push | |
| klaviyo.push = function (request) { | |
| if (request[0] === "identify") { | |
| // if someone attempts to identify the email address, unoverride push | |
| if (Object.keys(request[1]).includes("$email")) { | |
| klaviyo.push = klaviyo.old_push; | |
| klaviyo.push(["identify", { $email: request[1]["$email"] }]) | |
| // then push everything in localstorage as a raw request |
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
| function localStorageAvailable() { | |
| var test = "test" | |
| try { | |
| localStorage.setItem(test, test) | |
| localStorage.removeItem(test) | |
| return true | |
| } catch (e) { | |
| return false | |
| } | |
| } |
NewerOlder