Jump to content

Add Facebook Tracking to Checkout Page


pauloray

Recommended Posts

You can alse edit your whmcs header template file and add something like this:

 

{if $pagetitle eq $LANG.carttitle}

{literal}

---your code---

{/literal}

{/if}

 

This will target all cart-related pages, just like the hook

yes it can be but hooks are better for this.

 

@pauloray

your hook could be like this:

<?php

function hook_facebookTrackingCode($vars){

   if ($vars['filename']=='cart'){
       $facebookcode = '<script type="text/javascript">';
       $facebookcode .= '// Your JS Code Here';
       $facebookcode .= '</script>';
   }

return $facebookcode;
}
add_hook("ClientAreaHeadOutput", 1, "hook_facebookTrackingCode");

?>

Link to comment
Share on other sites

yes it can be but hooks are better for this.

 

@pauloray

your hook could be like this:

<?php

function hook_facebookTrackingCode($vars){

   if ($vars['filename']=='cart'){
       $facebookcode = '<script type="text/javascript">';
       $facebookcode .= '// Your JS Code Here';
       $facebookcode .= '</script>';
   }

return $facebookcode;
}
add_hook("ClientAreaHeadOutput", 1, "hook_facebookTrackingCode");

?>

 

 

Thank you, I will try this code.

 

Because I need to add our Facebook Conversion Tracking code to the Checkout page only.

The one that has a URL of like http://www.clientarea.yourdomain.com/cart.php?a=checkout.

 

Because we want to track for paid orders only, we have a separate code that goes to the whole cart by adding to the header.tpl

Link to comment
Share on other sites

then we can modify the IF Statement to:

   if ($vars['filename']=='cart' && $_GET['a']=='checkout'){
       $facebookcode = '<script type="text/javascript">';
       $facebookcode .= '// Your JS Code Here';
       $facebookcode .= '</script>';
   }

 

Thanks a lot @sentq.

 

And I will need to put this php file inside /includes/hooks right?

Link to comment
Share on other sites

then we can modify the IF Statement to:

   if ($vars['filename']=='cart' && $_GET['a']=='checkout'){
       $facebookcode = '<script type="text/javascript">';
       $facebookcode .= '// Your JS Code Here';
       $facebookcode .= '</script>';
   }

 

Thanks, I am using this code and is now working perfectly. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated