Skip to content

Instantly share code, notes, and snippets.

View leadbi's full-sized avatar

LeadBI leadbi

View GitHub Profile
@leadbi
leadbi / form_events.html
Created September 24, 2017 14:27
LeadBI Form Events Example
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>LeadBI Form Events </title>
</head>
<body onload="_load()" style="height: 2000px">
<h1>LeadBI Form Events</h1>
@leadbi
leadbi / token_example.php
Last active September 28, 2017 18:47
SwiftMTA Javacript Logs API
<?php
$username = 'dwtgroup';
$password = 'change_me';
$expire = date("c",strtotime("+1 day"));
$alg = 'sha256';
// generate authorization
$authorization = "$username;$expire;$alg";
$authorization = $authorization . ";" . hash_hmac($alg, $authorization, $password);
?>
@leadbi
leadbi / leadbi_api.py
Created December 13, 2017 10:18
LeadBI Python API Call Example
# LeadBI Python Api call example
import requests
import json
# Examples
# https://gist.github.com/leadbi/82235eedc9619d33a7c7e0ba71e41985
#
# API Calls
# https://gist.github.com/leadbi/4c46c91d4f2d6fb5a3ef431c1414564b
#
@leadbi
leadbi / LeadBiAPI.php
Last active January 19, 2018 16:19
LeadBI API PHP Example
<?php
/**
* LeadBI API PHP Wrapper
*/
class LeadBiAPI {
/**
* API access id (can be created in Account -> API Keys)
*/
@leadbi
leadbi / remove_utm.js
Last active February 15, 2018 13:50
Remove UTM params from query
(function () {
// remove url param
function removeUrlParam(url, paramName) {
var pattern = new RegExp('\\b(' + paramName + '=).*?(&|$)');
if (url.search(pattern) >= 0) {
return url.replace(pattern, '');
}
return url;
}
@leadbi
leadbi / leadbi_shop_api.js
Last active March 12, 2021 18:49
LeadBI ECommerce JavaScript API
// LeadBI Shop API
// Shop.identify(user, callback)
window.$leadbi_website.getCurrentUser(function (err, user) {
return user.getShop(function (err, shop) {
return shop.identify({
first_name: 'Andrei', // optional
last_name: 'Tofan', // optional
email: 'andrei@leadbi.com', // required
company: 'LeadBI', // optional
@leadbi
leadbi / dynamic_content.md
Last active August 28, 2018 07:28
LeadBI Dynamic Content

LeadBI Dynamic Content

This feature allows you to pull data from LeadBI into your website pages. Example:

Hello <{{ first_name | Dear Visitor }}>, welcome to our website.

The snippet from above will try to use the first name from LeadBI, if the user is not identified will use "Dear Visitor".

@leadbi
leadbi / node_send_form.js
Created October 18, 2020 16:45
LeadBI Form Webhook
fetch("https://capi.leadbi.com/forms/{replace_with_form_id}/submit", {
"headers": {
"content-type": "application/json",
},
"body": "{\"first_name\":{\"value\":\"Andrei\",\"name\":\"first_name\",\"type\":\"first_name\"},\"last_name\":{\"value\":\"Tofan\",\"name\":\"last_name\",\"type\":\"last_name\"},\"email\":{\"value\":\"admin@leadbi.com\",\"name\":\"email\",\"type\":\"email\"},\"phone\":{\"value\":\"+00723232322132\",\"name\":\"phone\",\"type\":\"phone_number\"}}",
"method": "POST"
});
@leadbi
leadbi / JavaAPIExample.java
Created April 1, 2021 18:35
LeadBI Java Example
import java.io.IOException;
import java.io.Serializable;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse.BodyHandlers;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@leadbi
leadbi / cookie-consent-example.html
Last active April 28, 2021 20:04
LeadBI Cookie Consent integration