Skip to content

Integration with Platformalp

To pass data correctly from the Platformlp website builder to R7K12CRM, follow these steps:

  1. Go to the page editor and open the form settings by clicking the wrench icon.

  1. On the “Actions after submission” tab, select the “Message + Insert HTML code” option.

  1. Copy one of the code options, depending on the number of products being passed.

To send only one product:

<script>
    var KEY = "XXXXXXXXXXXXXXXXXXXXXXXXX";
    function getSessionId() {
        try {
            if (window['r7k12_si']) {
                return window['r7k12_si'];
            }
            let r7k12_si = document.cookie.match(/r7k12_si=([^;$]+)/);
            if (r7k12_si && r7k12_si[1]) {
                return r7k12_si[1];
            }
            r7k12_si = window.localStorage.getItem('r7k12_si');
            if (r7k12_si) {
                return r7k12_si;
            }
            return false;
        }
        catch (e) {
            return false;
        }
    }
    function getXHR() {
        if (XMLHttpRequest) {
            try {
                return new XMLHttpRequest();
            }
            catch (e) {
            }
        }
        else if (ActiveXObject) {
            try {
                return new ActiveXObject('Msxml2.XMLHTTP');
            }
            catch (e) {
            }
            try {
                return new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e) {
            }
        }
        return null;
    }
    function SEND(REQUEST) {
        let method = REQUEST.method ? REQUEST.method : 'POST', url = REQUEST.url.replace(/#.*$/, '') + (method === 'GET' && REQUEST.query ? '?' + REQUEST.query : '') + (method === 'POST' && REQUEST.postGET ? '?' + REQUEST.postGET : ''), json = REQUEST.json ? REQUEST.json : false, query = method === 'POST' && REQUEST.query ? REQUEST.query : null, xhr = getXHR();
        xhr.open(method, url, true);
        if (method === 'POST' && json === false) {
            xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        }
        xhr.send(query);
        if (REQUEST.func) {
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    REQUEST.func(xhr);
                }
            };
        }
    }
    function crm(data) {
        if (data === void 0) {
            data = {};
        }
        data.r7k12id = getSessionId();
        data.href = document.location.href;
        if (data.phone && data.phone.match(/^0/)) {
            data.phone = '+38' + data.phone;
        }
        SEND({
            url: 'https://r7k12.com/' + KEY + '/crm/',
            json: true,
            query: JSON.stringify(data)
        });
    }
    var products = [
        {
            'id': '1',
            'name': 'тестовый товар',
            'price': '300',
            'quantity': '1',
        }
    ];
    var revenue = products.map(function(x) {return parseFloat(x.price) * parseFloat(x.quantity)}).reduce(function(a, c) { return a + c}).toFixed(2);
    var CRM = {
        'type': 'Form',
        'comment': 'Название товара',
        'name': '<%= name %>',
        'email': '<%= email %>',
        'phone': '<%= phone %>',
        'fields': {
            'lead': {
                'products': products,
                'revenue': revenue,
            },
            'contact': {
            },
        },
    };
    crm(CRM);

</script>

To send two products:

<script>
    var KEY = "XXXXXXXXXXXXXXXXXXXXXXXXX";
    function getSessionId() {
        try {
            if (window['r7k12_si']) {
                return window['r7k12_si'];
            }
            let r7k12_si = document.cookie.match(/r7k12_si=([^;$]+)/);
            if (r7k12_si && r7k12_si[1]) {
                return r7k12_si[1];
            }
            r7k12_si = window.localStorage.getItem('r7k12_si');
            if (r7k12_si) {
                return r7k12_si;
            }
            return false;
        }
        catch (e) {
            return false;
        }
    }
    function getXHR() {
        if (XMLHttpRequest) {
            try {
                return new XMLHttpRequest();
            }
            catch (e) {
            }
        }
        else if (ActiveXObject) {
            try {
                return new ActiveXObject('Msxml2.XMLHTTP');
            }
            catch (e) {
            }
            try {
                return new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e) {
            }
        }
        return null;
    }
    function SEND(REQUEST) {
        let method = REQUEST.method ? REQUEST.method : 'POST', url = REQUEST.url.replace(/#.*$/, '') + (method === 'GET' && REQUEST.query ? '?' + REQUEST.query : '') + (method === 'POST' && REQUEST.postGET ? '?' + REQUEST.postGET : ''), json = REQUEST.json ? REQUEST.json : false, query = method === 'POST' && REQUEST.query ? REQUEST.query : null, xhr = getXHR();
        xhr.open(method, url, true);
        if (method === 'POST' && json === false) {
            xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        }
        xhr.send(query);
        if (REQUEST.func) {
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    REQUEST.func(xhr);
                }
            };
        }
    }
    function crm(data) {
        if (data === void 0) {
            data = {};
        }
        data.r7k12id = getSessionId();
        data.href = document.location.href;
        if (data.phone && data.phone.match(/^0/)) {
            data.phone = '+38' + data.phone;
        }
        SEND({
            url: 'https://r7k12.com/' + KEY + '/crm/',
            json: true,
            query: JSON.stringify(data)
        });
    }
    var products = [
        {
            'id': '1',
            'name': 'тестовый товар',
            'price': '20',
            'quantity': '1',
        },
        {
            'id': '2',
            'name': 'тестовый товар 2',
            'price': '50',
            'quantity': '1',
        }
    ];
    var revenue = products.map(function(x) {return parseFloat(x.price) * parseFloat(x.quantity)}).reduce(function(a, c) { return a + c}).toFixed(2);
    var CRM = {
        'type': 'Form',
        'comment': 'Название товара',
        'name': '<%= name %>',
        'email': '<%= email %>',
        'phone': '<%= phone %>',
        'fields': {
            'lead': {
                'products': products,
                'revenue': revenue,
            },
            'contact': {
            },
        },
    };
    crm(CRM);

</script>
  1. Return to the Platformlp website and paste the copied code into the “Code to insert” field.

  1. Log in to your project on the R7K12CRM website and open the “Settings” menu. Copy the project key and replace the value of the KEY variable in the code with it.

  1. Publish the page and check the changes in Platformlp.