I have a 3rd party CRM system for mailing, and want to set up product interest and abandoned cart flows.
For this i have inserted a tracking code on the site, and then in the guide to the setup it just says to instert a visit event on product pages for product interest and it should look like this: hlt.visit(PRODUCTID, CATEGORYID, CATEGORYNAME); where PRODUCTID, CATEGORYID and CATEGORYNAME should be replaced with the params used on the site.
I have no idea how to find out which parameter my site uses for e.g productid.
How do i figure this out?
The script looks something like this for the product page:
<script type="text/javascript" language="javascript">
var hlt;
var BiTrackingLoaded = function (BiTracking) {
hlt=BiTracking;
BiTracking.initialize('INSERTAPIKEYHERE', INSERTSESSIONTIMEHERE);
hlt.visit(“PRODUCTID”,”CATEGORYID”,"CATEGORYNAME") }
</script>
<script>
(function (d, t) {
var g = d.createElement(t),
s = d.getElementsByTagName(t)[0];
h = "https:" == document.location.protocol ? "https://" : "http://";
g.src = h + 'tracking.heycommerce.dk/hlbi.js';
s.parentNode.insertBefore(g, s);
}
(document, 'script'));
</script>
To track the product interest try the following:
Add the script via your child theme functions.php
add_action('wp_head', 'zz_add_tracking_codes');
function zz_add_tracking_codes(){
// adding on product page only
if(is_singular( 'product' )){
$produc_id = get_the_id();
// Remember a product can have multiple categories so if you can only add one you get the frist element form array.
$categories = get_the_terms( $produc_id, 'product_cat');
?>
<script type="text/javascript" language="javascript">
const PRODUCTID = '<?php echo $produc_id; ?>';
const CATEGORYID = '<?php echo $categories[0]->term_id; ?>';
const CATEGORYNAME = '<?php echo $categories[0]->name; ?>';
var hlt;
var BiTrackingLoaded = function (BiTracking) {
hlt=BiTracking;
BiTracking.initialize('INSERTAPIKEYHERE', INSERTSESSIONTIMEHERE);
hlt.visit(PRODUCTID,CATEGORYID,CATEGORYNAME) }
</script>
<script>
(function (d, t) {
var g = d.createElement(t),
s = d.getElementsByTagName(t)[0];
h = "https:" == document.location.protocol ? "https://" : "http://";
g.src = h + 'tracking.heycommerce.dk/hlbi.js';
s.parentNode.insertBefore(g, s);
}
(document, 'script'));
</script>
<?php
}
}