Reputation: 11
I have this tacking code that is working good with php
<script type="text/javascript" id="pap_x2s6df8d" src="https://www.linkaraby.com/scripts/2xjh8l8dq0"></script>
<script type="text/javascript">
PostAffTracker.setAccountId('cc4af062');
<?php
$i = 0;
$total = 0;
$pid "";
foreach ($products as $item) {
$total += $item['total'];
$pid .= $item['product_id']. ";";
$i++; }
echo "var sale = PostAffTracker.createSale();";
echo "sale.setTotalCost('". $total ."');";
echo "sale.setProductID('". $pid ."');";
echo "sale.setOrderID('". $order_id ."');";
echo "sale.setCoupon('". $Coupon_Code ."');"
?>
PostAffTracker.register(); </script>
but my frontend is vue I did something like this
1-load javascript link on page mounted
mounted() {
let linkAraby = document.createElement('script')
linkAraby.setAttribute('src', 'https://www.linkaraby.com/scripts/2xjh8l8dq0')
linkAraby.setAttribute('id', 'pap_x2s6df8d');
linkAraby.setAttribute('type', 'text/javascript');
document.head.appendChild(linkAraby);
},
2- add new method for handle create Sale
linkArabys(){
window.PostAffTracker.setAccountId('cc4af062');
let sale = window.PostAffTracker.createSale();
sale.setTotalCost('55');
sale.setProductID('0');
sale.setOrderID('7');
sale.setCoupon('0')
window.PostAffTracker.register();
}
Is this method correct or is there another way to add the tracking code(post affiliate pro) to the sites designed by vue
Upvotes: 0
Views: 191
Reputation: 11
linkArabys(){
window.PostAffTracker.setAccountId(this.settings.link_araby_accountid.toString());
window.sale = window.PostAffTracker.createSale();
window.sale.setTotalCost((this.settings.price_with_vat == 1) ? (this.order_data.sub_total - this.order_data.discount + this.payment_form.tax) : this.order_data.sub_total);
window.sale.setProductID('0');
window.sale.setOrderID(this.order_data.code);
window.sale.setCoupon('0')
window.PostAffTracker.register();
}
this working for me
Upvotes: 0