Jump to content

Tracking pixel on Order Paid


DennisHermannsen

Recommended Posts

Hi,

 

Any ideas how this could be accomplished? We need different tracking pixels on 'order complete' for different products.

If client buys and pays for Product A, one pixel should be shown in the code. If client buys and pays for Product B, some other pixel should be shown. I'm trying to add this as a hook, but I'd really appreciate some help.

 

It should also be said that the pixel should be visible on a page that will always be shown after client has paid for the invoice.

Link to comment
Share on other sites

With an action hook that adds the necessary javascript to complete order page. Something like follows:

<?php

function customPrefix_ClientAreaPage($vars)
{
    if (($vars['filename'] == 'cart') AND ($_GET['a'] == 'complete'))
    {
        $pid = '1'; // Select IDs of all products/services on invoice with a query and add as many 'contents' you need in tracking code

        echo "<script>fbq('track', 'Purchase', { contents: [{ id: '{$pid}', quantity: 1, item_price: 0 }], });</script>";
    }

    return $output;
}

add_hook('ClientAreaPage', 10, 'customPrefix_ClientAreaPage');

 

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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