My Sellerdeck Account | Free Trial

Sellerdeck Community and Knowledge Base

  #1  
Old 23-Sep-2017, 04:43 PM
graphicz's Avatar
graphicz graphicz is offline
Registered User
Join Date: May 2007
Full Name: Jonathan Chappell
Posts: 784
Thanks: 74
Thanked 111 Times in 88 Posts
Facebook Pixel Code

This is what I am adding for comment or correction or for you to use:

Code:
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window,document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '12345678123456678');
fbq('track', 'PageView');
<actinic:block if="%3cactinic%3avariable%20name%3d%22PageTitle%22%20%2f%3e%20%3d%3d%20%22Newsletter%20Sign%20Up%22" >
	fbq('track', 'CompleteRegistration');
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22IsBrochureHomePage%22%20%2f%3e">
	fbq('track', 'ViewContent');
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Product%20Page%22" >
	fbq('track', 'ViewContent');
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Search%20Results%22">
	fbq('track', 'Search');
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Add%20To%20Cart%20Confirmation%22" >
	fbq('track', 'AddToCart');
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Checkout%20Page%200%22" >
	fbq('track', 'InitiateCheckout');
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Checkout%20Page%202%22">
	fbq('track', 'AddPaymentInfo');
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Receipt%22" >
	fbq('track', 'Purchase', {value: '<actinic:variable encoding="perl" name="Total" selectable="false" />', currency: 'GBP'});
</actinic:block>
</script>
<noscript>
<img height="1" width="1"
src="https://www.facebook.com/tr?id=1234567812345678&ev=PageView
&noscript=1"/>
</noscript>
<!-- End Facebook Pixel Code -->
I have also put the same code with the ViewContent tag in the Wordpress Header when sites have associated blogs:

Code:
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window,document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '1234567812345678');
fbq('track', 'PageView');
fbq('track', 'ViewContent');
</script>
<noscript>
<img height="1" width="1"
src="https://www.facebook.com/tr?id=1234567812345678&ev=PageView
&noscript=1"/>
</noscript>
<!-- End Facebook Pixel Code -->
Thank you.
__________________
Jonathan Chappell
Website Designer
SellerDeck Website Designer
Actinic to SellerDeck upgrades
Graphicz Limited - www.graphicz.co.uk
Reply With Quote
The Following 2 Users Say Thank You to graphicz For This Useful Post:
Duncan Rounding (24-Sep-2017), Mike Hughes (25-Sep-2017)
  #2  
Old 09-Jan-2018, 11:59 AM
graphicz's Avatar
graphicz graphicz is offline
Registered User
Join Date: May 2007
Full Name: Jonathan Chappell
Posts: 784
Thanks: 74
Thanked 111 Times in 88 Posts
Problem with 'Total'

I have a problem with the above code and I would be grateful for some help.

The line:

Code:
<actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Receipt%22" >
	fbq('track', 'Purchase', {value: '<actinic:variable encoding="perl" name="Total" selectable="false" />', currency: 'GBP'});
</actinic:block>
Is generating errors on the Pixel validation page: I is producing the value:

Code:
{"value":"NETQUOTEVAR:TOTAL","currency":"GBP"}
Rather than a numeric figure for the Cart/Order Total. Is there a 'Raw' variable that can be used here istead of <actinic:variable encoding="perl" name="Total" selectable="false" />

Or should the encoding be something else?

Or should it be wrapped in <Actinic:XMLTEMPLATE NAME="ShoppingCart"> tags???

Thank you
__________________
Jonathan Chappell
Website Designer
SellerDeck Website Designer
Actinic to SellerDeck upgrades
Graphicz Limited - www.graphicz.co.uk
Reply With Quote
  #3  
Old 12-Feb-2018, 01:42 PM
MattSMR MattSMR is offline
Registered User
Join Date: Dec 2016
Full Name: Matt McCullough
Posts: 71
Thanks: 11
Thanked 16 Times in 12 Posts
Hi Jonathan,

Did you ever make any progress with this? Just setting up our pixel now & had a Google first.

If I get any joy - I'll feed back here.
__________________
Matt. M - SMR Enterprises Ltd.
Reply With Quote
  #4  
Old 12-Feb-2018, 02:15 PM
graphicz's Avatar
graphicz graphicz is offline
Registered User
Join Date: May 2007
Full Name: Jonathan Chappell
Posts: 784
Thanks: 74
Thanked 111 Times in 88 Posts
It was the uneccessary additions to the variable:
Code:
<actinic:variable encoding="perl" name="Total" selectable="false" />
It just needs to be this:

Code:
<actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Receipt%22" >
	fbq('track', 'Purchase', {value: '<actinic:variable name="Total" />', currency: 'GBP'});
</actinic:block>
However I had a similar issue with Trustpilot integration and the wonderful Norman wrote this:

Code:
<!-- Trustpilot conversion script -->
<script type="text/javascript">
// SellerDeck tweaks start
// SellerDeck amount may have  sign and thousand commas
function getcartamount(){
	return ('<Actinic:Variable Name="Total"/>').replace(/[^0-9\.]/g, '');
}

// we've added a cartqtyfield class-name to the Qty field in the checkout
function getcarttotalitems(){
	var basket_size = 0;
	$( ".cartqtyfield" ).each(function(){
		var itemcount = $(this).text();
		if ( ! isNaN(itemcount) )
			{
			basket_size += itemcount - 0;
			}
		});
	return basket_size;
}
// SellerDeck tweaks end

// TP code continues
(function(c,o,n,v,e,r,t){c['TPConversionObject']=e;c[e]=c[e]||function(){c[e].buid='xxxxxxxxxxxxxxxxxxxxxxxx',(c[e].q=c[e].q||[]).push(arguments)};r=o.createElement(n),t=o.getElementsByTagName(n)[0];r.async=1;r.src=v;t.parentNode.insertBefore(r,t)})(window,document,'script','https://widget.trustpilot.com/conversion/conversion.js','tpConversion');

tpConversion('amount', getcartamount()); // total cost of the order, eg. '13.00'
tpConversion('currency', 'GBP'); // your shop's currency, e.g. USD
tpConversion('basket_size', getcarttotalitems()); // total number of items purchased
</script>
<!-- End Trustpilot conversion script -->
In fact you chimed in on the thread!

Code:
http://community.sellerdeck.com/showthread.php?t=57476
Best wishes!
__________________
Jonathan Chappell
Website Designer
SellerDeck Website Designer
Actinic to SellerDeck upgrades
Graphicz Limited - www.graphicz.co.uk
Reply With Quote
The Following User Says Thank You to graphicz For This Useful Post:
MattSMR (12-Feb-2018)
  #5  
Old 12-Feb-2018, 02:52 PM
MattSMR MattSMR is offline
Registered User
Join Date: Dec 2016
Full Name: Matt McCullough
Posts: 71
Thanks: 11
Thanked 16 Times in 12 Posts
What a gentleman - thank you.

You simply dropped this in during the HTML header?
__________________
Matt. M - SMR Enterprises Ltd.
Reply With Quote
  #6  
Old 12-Feb-2018, 03:09 PM
NormanRouxel's Avatar
NormanRouxel NormanRouxel is offline
Registered User
Join Date: Dec 2002
Full Name: Norman Rouxel
Posts: 10,793
Thanks: 9
Thanked 761 Times in 635 Posts
Note that <Actinic:Variable Name="Total"/>

May return text like 12,345.67 and your external code may expect just

12345.67 so that's what the:
Code:
('<Actinic:Variable Name="Total"/>').replace(/[^0-9\.]/g, '')
does.
__________________
Norman - www.drillpine.biz
Edinburgh, U K / Bitez, Turkey
Reply With Quote
The Following 2 Users Say Thank You to NormanRouxel For This Useful Post:
graphicz (12-Feb-2018), MattSMR (12-Feb-2018)
  #7  
Old 12-Feb-2018, 03:15 PM
MattSMR MattSMR is offline
Registered User
Join Date: Dec 2016
Full Name: Matt McCullough
Posts: 71
Thanks: 11
Thanked 16 Times in 12 Posts
Quote:
Originally Posted by NormanRouxel View Post
Note that <Actinic:Variable Name="Total"/>

May return text like 12,345.67 and your external code may expect just

12345.67 so that's what the:
Code:
('<Actinic:Variable Name="Total"/>').replace(/[^0-9\.]/g, '')
does.
Thanks Norman,

I believe that FB are able to interpret the currency literally, as they have asked specifically what currency and format is being used - I'll let you know once I've tested.
__________________
Matt. M - SMR Enterprises Ltd.
Reply With Quote
  #8  
Old 12-Feb-2018, 03:27 PM
graphicz's Avatar
graphicz graphicz is offline
Registered User
Join Date: May 2007
Full Name: Jonathan Chappell
Posts: 784
Thanks: 74
Thanked 111 Times in 88 Posts
Thank you Norman!

Yes Matt, bottom of Javascript Header Functions, then it will be on all pages including receipt wihich has a different outer layout.
__________________
Jonathan Chappell
Website Designer
SellerDeck Website Designer
Actinic to SellerDeck upgrades
Graphicz Limited - www.graphicz.co.uk
Reply With Quote
  #9  
Old 12-Feb-2018, 04:58 PM
graphicz's Avatar
graphicz graphicz is offline
Registered User
Join Date: May 2007
Full Name: Jonathan Chappell
Posts: 784
Thanks: 74
Thanked 111 Times in 88 Posts
I am not very good at javascript.
Would something like this work?
Code:
var carttotal = ('<Actinic:Variable Name="Total"/>').replace(/[^0-9\.]/g, '');
	fbq('track', 'Purchase', {value: 'document.write(carttotal)', currency: 'GBP'});
__________________
Jonathan Chappell
Website Designer
SellerDeck Website Designer
Actinic to SellerDeck upgrades
Graphicz Limited - www.graphicz.co.uk
Reply With Quote
  #10  
Old 12-Feb-2018, 05:18 PM
NormanRouxel's Avatar
NormanRouxel NormanRouxel is offline
Registered User
Join Date: Dec 2002
Full Name: Norman Rouxel
Posts: 10,793
Thanks: 9
Thanked 761 Times in 635 Posts
Just
Code:
	fbq('track', 'Purchase', {value: ('<Actinic:Variable Name="Total"/>').replace(/[^0-9\.]/g, ''), currency: 'GBP'});
__________________
Norman - www.drillpine.biz
Edinburgh, U K / Bitez, Turkey
Reply With Quote
  #11  
Old 12-Feb-2018, 06:16 PM
graphicz's Avatar
graphicz graphicz is offline
Registered User
Join Date: May 2007
Full Name: Jonathan Chappell
Posts: 784
Thanks: 74
Thanked 111 Times in 88 Posts
Thank you so much.
__________________
Jonathan Chappell
Website Designer
SellerDeck Website Designer
Actinic to SellerDeck upgrades
Graphicz Limited - www.graphicz.co.uk
Reply With Quote
  #12  
Old 13-Feb-2018, 08:36 AM
graphicz's Avatar
graphicz graphicz is offline
Registered User
Join Date: May 2007
Full Name: Jonathan Chappell
Posts: 784
Thanks: 74
Thanked 111 Times in 88 Posts
Using Chrome's Pixel helper that shows the price as NETQUOTEVAR:

Code:
EVENT INFO
URL Called: Show
Load Time: 13.33 ms
Pixel Code: Hide
fbq('track', 'Purchase', {value: ('NETQUOTEVAR:TOTAL')
Pixel Location: Show
Frame: Window
__________________
Jonathan Chappell
Website Designer
SellerDeck Website Designer
Actinic to SellerDeck upgrades
Graphicz Limited - www.graphicz.co.uk
Reply With Quote
  #13  
Old 13-Feb-2018, 10:56 AM
MattSMR MattSMR is offline
Registered User
Join Date: Dec 2016
Full Name: Matt McCullough
Posts: 71
Thanks: 11
Thanked 16 Times in 12 Posts
Hi Jonathan,

Every event but the purchase fired successfully overnight - as I can see you're battling this too!

I'll be doing some work on this on our development server later, if I reach a solution I'll let you know.

I'm inclined to look at the GA integration as that captures transaction values successfully.
__________________
Matt. M - SMR Enterprises Ltd.
Reply With Quote
  #14  
Old 13-Feb-2018, 11:18 AM
MattSMR MattSMR is offline
Registered User
Join Date: Dec 2016
Full Name: Matt McCullough
Posts: 71
Thanks: 11
Thanked 16 Times in 12 Posts
The field I use for GA conversion value is as follows:

var google_conversion_value = NETQUOTEVAR:ORDERTOTALBASEUNIT;

Wondering if it's possible to bring this inline.
__________________
Matt. M - SMR Enterprises Ltd.
Reply With Quote
  #15  
Old 13-Feb-2018, 04:26 PM
jtaylor jtaylor is offline
Administrator
Join Date: Feb 2018
Full Name: Justin Taylor
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Matt,

A small v18 teaser - Facebook Pixel event tracking will be natively available within the software. But I bet there's a way to get it working as you're doing now!

Cheers,
Justin
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 11:08 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.