Installation + Pixels
Use our JavaScript API on your website and application to track events and deliver engaging digital experiences.
Our JavaScript code is async and can't delay your website speed
Base Pixel
Make sure to change the ACCOUNT ID for the base pixel
<script>
'use strict'; (function (a, b, c) { if (!a.flashy) { a.flashy = function () { a.flashy.event && a.flashy.event(arguments), a.flashy.queue.push(arguments) }, a.flashy.queue = []; var d = document.getElementsByTagName('script')[0], e = document.createElement(b); e.src = c, e.async = !0, d.parentNode.insertBefore(e, d) } })(window, 'script', 'https://js.flashyapp.com/thunder.js'),
flashy('init', __ACCOUNT_ID__); // Make sure to change the Account ID.
</script>
Page View
Add this pixel only on a general pages, not product pages
<script>
flashy('PageView');
</script>
View Content
Add on product pages with the product ID
<script>
flashy('ViewContent', {
'content_ids': ["product_1"]
});
</script>
Update Cart
We recommend to use the UpdateCart to sync all the cart contents, when product removed from the cart or quantity changed or new product added
<script>
flashy('UpdateCart', {
'content_ids': ["product_id"],
'value': 100,
'currency': 'USD'
});
</script>
Add To Cart
We suggest to use the UpdateCart instead of AddToCart
<script>
flashy('AddToCart', {
'content_ids': ["product_ids", "products_1"],
'value': 100,
'currency': 'USD'
});
</script>
Purchase
Send the products ID's in array of strings: ["123", "456"]
To make sure order not being tracked more than once use the ORDER ID parameter
<script>
flashy('Purchase', {
'content_ids': ["product_id"],
'value': 100,
'currency': 'USD',
'order_id': '__ORDER_ID__'
});
</script>
Purchase Updated
Update purchase after status has been update - pending, delivered you can use any string and start automation based on the purchase status
<script>
flashy('PurchaseUpdated', {
'status': 'PENDING',
'order_id': '__ORDER_ID__',
'content_ids': ["product_id"], // Optional
'value': 100, // Optional
'currency': 'USD' // Optional
});
</script>
Subscribe Contact To a List
If you want to create & subscribe contacts from the front-end you can use this pixel or you can use our REST API and create the contact from the backend.
You can create contact and also subscribe him to a list, you need the LIST-ID to use that
<script>
flashy.contacts.create({
"email": "email@address.com",
"first_name": "John",
"last_name": "Doe",
}, LIST-ID);
</script>
Subscribe Contact Without List
If you want to create contact without subscribing from the front-end you can use this pixel or you can use our REST API and create the contact from the backend.
You can create contact without subscribing him to a list
<script>
flashy.contacts.create({
"email": "email@address.com",
"first_name": "John",
"last_name": "Doe",
});
</script>
Set Contact By Email
Use this function to set the visitor email address, every action after (page views, add to cart), will be added to the contact profile We automatically use this function when the URL has email parameter: https://websiteurl.com/?email=email@address.com
<script>
flashy('setCustomer', {
"email": "email@address.com"
});
</script>
Custom Events
<script>
flashy('CustomEvent', {
"event_name": "SpecificAction"
});
</script>
Check If A Visitor Is Anonymous
Before you can update contacts from JS you need to make sure they are not anonymous.
<script>
if( !flashy.contacts.anonymous() )
{
// Do anything you want...
}
</script>
Update Contact
Make sure the visitor on the website is not anonymous.
<script>
flashy.contacts.update({
"first_name": "Sam",
"anything": "You want"
});
</script>
Make sure you use Flashy global on ready only, we have event listen when it's ready and it's a best practice to wrap any function with it.
Update Or Create
You can update or create new contact if not exists and include the lists + the status for each list.
flashy.contacts.createOrUpdate({
"email": "email@domain.com",
"first_name": "Rafael",
"last_name": "Mor",
"lists": {
15000: false
}
});
Make sure the lists
object is with the correct List ID - very important.
You can pass true or false and a few lists, where true
is allow marketing.
When Flashy Ready
<script>
window.addEventListener('onFlashy', function() {
// Flashy global vriable ready to be used.
// Use to Create / Update contacts from Flashy global variable
});
</script>
Flashy Helpers Events
On Popup Show:
<script>
window.addEventListener('flashyPopupShowed', ev => {
console.log(ev.detail.popup_id);
});
</script>
Popup Custom Event
If you want to show a popup based on custom event use the code below:
flashy('any-custom-even-you-want');