Hello, where can I add a php code snipet I was given to track users for email abandonment campaigns?
THis is the code:
<?php
$ImageUrl = wp_get_attachment_image_src( get_post_thumbnail_id( $loop->post->ID ), ‘single-post-thumbnail’ )[0];
$ItemId = $product->id;
$Title = $product-> get_title();
$ProductUrl = “http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]”;
$Price = $product->get_price();
$RegularPrice = $product->get_regular_price();
$DiscountAmount = $RegularPrice – $Price;
$terms = get_terms( ‘product_tag’ );
?>
<script>
var Title = “<?php echo $Title; ?>”;
var ItemId = “<?php echo $ItemId; ?>”;
var ImageUrl = “<?php echo $ImageUrl; ?>”;
var ProductUrl = “<?php echo $ProductUrl; ?>”;
var Price = “<?php echo $Price; ?>”;
var DiscountAmount = “<?php echo $DiscountAmount; ?>”;
var RegularPrice = “<?php echo $RegularPrice; ?>”;
var _learnq = _learnq || [];
_learnq.push([‘track’, ‘Viewed Product’, {
Title: Title,
ItemId: ItemId,
ImageUrl: ImageUrl,
Url: ProductUrl,
Metadata: {
Price: Price,
DiscountAmount: DiscountAmount,
RegularPrice: RegularPrice
}
}]);
</script>
Thank you!