Adding a tracking pixel

Adding a tracking pixel in Zen Cart

FIXME please verify

Situation:

You’ve just signed up with an affiliate system who’s promised you the ultimate in statistics tracking, commission handling, referral monitoring, and more.

They’ve given you a snippet of code and instructed you to place it on your site, after replacing some parameters with actual values of orders in your store. But you don’t know where to put this new code.

Solution:

1. First, you need to make sure you have an appropriate override file in place.

THERE ARE TWO OPTIONS:
a) javascript file (recommended)
To do it with a javascript file, simply create the following file:
/includes/modules/pages/checkout_success/jscript_myaffiliate_program.php

b) template file:
To do it with a template file, you’ll need the following file on your server: /includes/templates/YOURTEMPLATE/checkout_success/tpl_footer.php (replacing YOURTEMPLATE with the name of your actual custom template, of course)
If you don’t already have that checkout_success folder at that location, create it. And then copy the tpl_footer.php file from your /includes/templates/YOURTEMPLATE/common/tpl_footer.php … or if you don’t have one there, get it from template_default.

2. Using your favorite text editor, save the file, but leave it open in your editor.

3. Now, for each parameter that your affiliate company told you needs to be replaced dynamically, substitute the appropriate value from the table below:

**Value to replace** **What to replace it with**
Order Number <?php echo $order_summary['order_number']; ?>
Subtotal <?php echo $order_summary['order_subtotal']; ?>
Amount of credits/discounts on the order <?php echo $order_summary['credits_applied']; ?>
Final Total <?php echo $order_summary['order_total']; ?>
Commissionable Order Amount (does not include discounts) <?php echo $order_summary['commissionable_order']; ?>
Commissionable amount, formatted with dollar sign and decimal point (per currently selected currency formatting rules set in your admin) <?php echo $order_summary['commissionable_order_formatted']; ?>
Coupon Code, if any (often used for referral tracking) <?php echo $order_summary['coupon_code']; ?>
Currency Code (3-letter ISO code) <?php echo $order_summary['currency_code']; ?>
Exchange Rate applied, if any <?php echo $order_summary['currency_value']; ?>
Payment Module used <?php echo $order_summary['payment_module_code']; ?>
Shipping Method selected by customer <?php echo $order_summary['shipping_method']; ?>
Order Status (number) denoting the order's status in your store at this present time. <?php echo $order_summary['orders_status']; ?>
Tax on the order <?php echo $order_summary['tax']; ?>
Shipping Cost on the order <?php echo $order_summary['shipping']; ?>
Order Total (the final/net total of the order, the amount sent for payment) <?php echo $order_summary['order_total']; ?>
Product Model Numbers (delimited with "|") <?php echo $order_summary['products_ordered_models']; ?>
Product IDs (delimited with "|") <?php echo $order_summary['products_ordered_ids']; ?>

Save the file and upload it to your server, keeping in mind the correct folder location as explained in steps 1 and 2.

4. Test

Need to pass details of specific products ordered? See the additional variables outlined in the article linked below.

Related article: Integrating Sales Analytics/Affiliate Tools




Still have questions? No problem! Just head over to the Zen Cart support forum and ask there.
In your post, please include your Zen Cart and PHP versions, and a link to your site.


Last modified April 2, 2020 by Scott C Wilson (5dca14a).