Code:
<script> (function(w,d,t,u,n,a,m){w['MauticTrackingObject']=n;
w[n]=w[n]||function(){(w[n].q=w[n].q||[]).push(arguments)},a=d.createElement(t),
m=d.getElementsByTagName(t)[0];a.async=1;a.src=u;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://MAUTIC_INSTANCE_DOMAIN/mtc.js','mt');
mt('send', 'pageview'<?php //do not put new line here befor php
// If customer is logged in get infos from database
if ($_SESSION['customer_id'] ){
$MAUTIC_query = "SELECT
customers.customers_id,
customers.customers_firstname,
customers.customers_lastname,
customers.customers_email_address,
customers_info.customers_info_date_of_last_logon,
customers_info.customers_info_number_of_logons,
customers_info.customers_info_date_account_last_modified,
customers_info.customers_info_date_account_created,
orders.order_total,
SUM(orders.order_total) AS zc_orders_tot,
SUBSTRING_INDEX(orders.ip_address,' - ',1) AS ip_address1,
SUBSTRING_INDEX(orders.ip_address,' - ',-1) AS ip_address2,
reward_customer_points.reward_points,
reward_customer_points.pending_points,
customers.customers_newsletter,
customers.customers_dob,
customers.customers_gender,
customers.customers_email_format
FROM
customers
INNER JOIN
customers_info
ON
customers.customers_id = customers_info.customers_info_id
INNER JOIN
orders
ON
customers.customers_id = orders.customers_id
INNER JOIN
reward_customer_points
ON
customers.customers_id = reward_customer_points.customers_id
WHERE
customers.customers_id = " . $_SESSION['customer_id'] . "
GROUP BY
customers_info.customers_info_id
ORDER BY
reward_customer_points.reward_points DESC limit 1";
$MAUTIC_answer = $db->Execute($MAUTIC_query);
$MAUTIC_cust_id = $MAUTIC_answer->fields['customers_id']; // zc_cust_id
$MAUTIC_firstname = $MAUTIC_answer->fields['customers_firstname']; // firstname
$MAUTIC_lastname = $MAUTIC_answer->fields['customers_lastname']; // lastname
$MAUTIC_email = $MAUTIC_answer->fields['customers_email_address']; //email
$MAUTIC_last_logon = $MAUTIC_answer->fields['customers_info_date_of_last_logon']; // zc_last_logon
$MAUTIC_number_logons = $MAUTIC_answer->fields['customers_info_number_of_logons']; // zc_number_of_logons
$MAUTIC_last_modif = $MAUTIC_answer->fields['customers_info_date_account_last_modified']; // zc_date_account_last_modi
$MAUTIC_account_created = $MAUTIC_answer->fields['customers_info_date_account_created']; // zc_date_account_created
$MAUTIC_last_order_total = $MAUTIC_answer->fields['order_total']; // zc_last_order_total
$MAUTIC_all_orders_total = $MAUTIC_answer->fields['zc_orders_tot']; // zc_orders_total
$MAUTIC_ipaddress1 = $MAUTIC_answer->fields['ip_address1']; // zc_ip_address
$MAUTIC_ipaddress2 = $MAUTIC_answer->fields['ip_address2']; // zc_ip_address1
$MAUTIC_reward_points = $MAUTIC_answer->fields['reward_points']; // zc_reward_points
$MAUTIC_pending_points = $MAUTIC_answer->fields['pending_points']; // zc_pending_points
$MAUTIC_email_format = $MAUTIC_answer->fields['customers_email_format']; // zc_email_format
$MAUTIC_newsletter = $MAUTIC_answer->fields['customers_newsletter']; // zc_newsletter
$MAUTIC_date_ob = $MAUTIC_answer->fields['customers_dob']; // zc_date_ob
$MAUTIC_gender = $MAUTIC_answer->fields['customers_gender']; // zc_gender
// build JS syntax to feed Mautic
echo ", {email: '" . $MAUTIC_email .
"', firstname: '" . $_SESSION['customer_first_name'] .
"', lastname: '" . $MAUTIC_lastname .
"', zc_cust_id: '" . $MAUTIC_cust_id .
"', zc_last_logon: '" . $MAUTIC_last_logon .
"', zc_number_of_logons: '" . $MAUTIC_number_logons .
"', zc_date_account_last_modi: '" . $MAUTIC_last_modif .
"', zc_date_account_created: '" . $MAUTIC_account_created .
"', zc_last_order_total: '" . $MAUTIC_last_order_total .
"', zc_orders_total: '" . $MAUTIC_all_orders_total .
"', zc_ip_address: '" . $MAUTIC_ipaddress1 .
"', zc_ip_address1: '" . $MAUTIC_ipaddress2 .
"', zc_reward_points: '" . $MAUTIC_reward_points .
"', zc_pending_points: '" . $MAUTIC_pending_points .
"', zc_email_format: '" . $MAUTIC_email_format .
"', zc_newsletter: '" . $MAUTIC_newsletter .
"', zc_date_ob: '" . $MAUTIC_date_ob .
"', zc_gender: '" . $MAUTIC_gender .
"'}";
}
?>);
</script>
Bookmarks