Integración con Platformalp¶
Para que los datos se transmitan correctamente desde el constructor de sitios web Platformlp al servicio R7K12CRM, es necesario realizar los siguientes pasos:
- Ir al editor de la página y abrir la configuración del formulario haciendo clic en el icono de la llave inglesa.

- En la pestaña «Acciones después del envío», seleccionar la opción «Mensaje + Inserción de código HTML».

- Copiar una de las variantes del código según la cantidad de productos que se transmitan.
Para enviar un solo producto:
<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>
Para enviar dos productos:
<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>
- Volver al sitio de Platformlp y pegar el código copiado en el campo «Código para insertar».

- Entrar en su proyecto en el sitio de R7K12CRM y abrir el menú «Configuración». Copiar la clave del proyecto y sustituir con ella el valor de la variable KEY en el código.

- Publicar la página y comprobar los cambios en Platformlp.