Web SDK methods reference

Tracking user actions

Basic method for tracking events

For more details, click here.

SR.event.track("Add to favourites", {
    "eventLabel": "homePageFav",
    "name": "iPhone XR 128GB",
    "id": 247559,
    "price": "3899.00",
    "brand": "Apple",
    "category": "Smartphones",
    "variant": "Black"
})

Re-initialize the tracking code

You can use this method to re-initialize a search for the data-synerise attributes on a page. This is used, for example, in pop-up windows.

SyneriseTC.initFormCatch()

Managing user data

Send form data

This method allows you to send data from an HTML form to the SDK. This event is sent automatically when a user sends a form. For more details, click here.

SyneriseTC.sendFormData('contact', //form type
{ //form data
    surname: "Doe",
    name: "John",
    email: "john.doe@synerise.com"
},
{ //field mapping
    lastname: "surname",
    firstname: "name",
    email: "email"
},
[], //skip as attributes
function () {} //callback function
)

Send form data without a form

You can emulate the behavior of a form by calling the SDK directly.

SyneriseTC.sendFormData('contact', {
    lastname: "Doe",
    firstname: "John",
    email: "john.doe@synerise.com"
})

Send newsletter agreements

You can use this method to send a customer’s newsletter agreements. For more details, click here.

SyneriseTC.sendFormData('newsletter', {})

Tracking transactions

Transactions can be tracked using Google Data Layer or sent to the Synerise tracker, which uses an identical format.

Send a “product added to cart” event

dataLayer.push({
    'event': 'addToCart',
    'ecommerce': {
        'currencyCode': 'EUR',
        'add': {
            'products': [{
                'name': 'Triblend Android T-Shirt',
                'id': '12345',
                'price': '15.25',
                'brand': 'Google',
                'category': 'Apparel',
                'variant': 'Gray',
                'quantity': 1
            }]
        }
    }
})

Send a “product removed from cart” event

dataLayer.push({
    'event': 'removeFromCart',
    'ecommerce': {
        'remove': {
            'products': [{
                'name': 'Triblend Android T-Shirt',
                'id': '12345',
                'price': '15.25',
                'brand': 'Google',
                'category': 'Apparel',
                'variant': 'Gray',
                'quantity': 1
            }]
        }
    }
})

Send purchase details

dataLayer.push({
    'ecommerce': {
        'purchase': {
            'actionField': {
                'id': 'T12345',
                'affiliation': 'Online Store',
                'revenue': '35.43',
                'tax': '4.90',
                'shipping': '5.99',
                'coupon': 'SUMMER_SALE'
            },
            'products': [{
                    'name': 'Triblend Android T-Shirt',
                    'id': '12345',
                    'price': '15.25',
                    'brand': 'Google',
                    'category': 'Apparel',
                    'variant': 'Gray',
                    'quantity': 1,
                    'coupon': ''
                },
                {
                    'name': 'Donut Friday Scented T-Shirt',
                    'id': '67890',
                    'price': '33.75',
                    'brand': 'Google',
                    'category': 'Apparel',
                    'variant': 'Black',
                    'quantity': 1
                }
            ]
        }
    }
})

Enable syneriseLayer transaction tracking

You can use this method for transaction tracking if you’re not using Google Data Layer.

SR.init({
    'trackerKey':'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
    'dataLayer': window['syneriseLayer'] = []
});

Send a transaction to syneriseLayer

syneriseLayer queries are formatted in the same way as Google Data Layer queries.

syneriseLayer.push({...})
😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.