nican VIP
Total posts: 392
19 Mar 2018 09:45

Hello, I am trying to insert a purchase action for the facebook pixel in Emerald javascript action

I insert this code in the action without script tags as requested

  fbq('track', 'Purchase', {
    value: 10,
  });

but when testing it (purchasing the subscription) with facebook pixel helper (google chrome extension) I receive this error

fb-pixel-code-emerald-issue

this is what facebook says when I click for more info https://developers.facebook.com/docs/facebook-pixel/pixel-helper#did-not-load

any thoughts on what could be the issue?

I am using Joomla 3.8.5 + Emerald 9.402

Thank you

Last Modified: 19 Apr 2018


Sergey
Total posts: 13,748
04 Apr 2018 11:07

You have to load script where this method is sыуеюtry to use HTML field

<script src="/path/to/favebook/library"> </script>
<script>
fbq('track', 'Purchase', {
    value: 10,
  });
</stript>

nican VIP
Total posts: 392
08 Apr 2018 08:47

YOu mean like this?

Javascript code Without script tag

fbq('track', 'Purchase', {
    value: 10,
  });

HTML code in noscript

<img height="1" width="1" style="display:none"
  src="/ https://www.facebook.com/tr?id=497135833810934& ;ev=PageView&noscript=1"
/>

I ask because this 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', '497135833810934');
  fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
  src="/ https://www.facebook.com/tr?id=497135833810934& ;ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->

is already inserted in my site template, and it loads on all site pages Facebook pixel stats are working normally, it's just the purchase action that is not working

thank you


nican VIP
Total posts: 392
08 Apr 2018 09:25

I did some other tests but none of them seems to work... I tried insering the codes as showed in the post above as well as inserting the whole facebook pixel code in the Javascript code field in Emerald, I also tried as you suggested to insert in that same field

<script src="/ https://www.facebook.com/tr?id=497135833810934& ;ev=PageView&noscript=1"> </script>
<script>
fbq('track', 'Purchase', {
    value: 10,
  });
</script>

when testing with Facebook Pixel Helper, it always says that the Purchase action is not being registered because the code was not sent to FAcebook

could you test this on your side and let me know exactly what to insert in the Emerald JAvascript Action? That woudl great :)

thanks


Sergey
Total posts: 13,748
09 Apr 2018 09:36

Make sure that code in Emerald action is places in HTML source after Facebook Pixel Code you placed in template. Also look in console and see if there are any errors.


nican VIP
Total posts: 392
15 Apr 2018 15:40

it's still not clear to me how to fill the emerald action fields, I filled them as follows:

in Javascript code field I put:

<script src="/  https://www.facebook.com/tr?id=497135833810934& ; ;ev=PageView&noscript=1"> </script>
<script>
fbq('track', 'Purchase', {
    value: 10,
  });
</script>

HTML code in noscript field: I leave it empty

the Facebook pixel code inserted in my template is being loaded before the closing head tag, while the Facebook pixel code inserted in Emerald action is not being loaded (that is also the error I get with Facebook pixel helper chrome app) so I don't see it in the source code after purchasing a subscription

these are the errors I see in chrome console: console

It would be easier if you would tell me exactly how to filled the emerald action fields, I tried many different ways but none seem to work.

Thank you


Sergey
Total posts: 13,748
16 Apr 2018 11:00

If you have <script> tag you canot put it to JavaScript. Everything that you put in JS text will be wraped into <stript> tag. But HTML field is added as it is writen. SO if you put <script> tag there, it will turn into script.

SO add

<script src="/www.facebook.com/tr?id=497135833810934&..................."> </script>
<script>
fbq('track', 'Purchase', {
    value: 10,
  });
</script>

to HTML

Also in your example you have so many errors in URL / https://www.facebook.com/tr?id=497135833810934& ; ; ;ev=PageView&noscript=1. First it starts with / and then HTTPS, there some whitespaces. URL looks wrong.


nican VIP
Total posts: 392
17 Apr 2018 16:45

Also in your example you have so many errors in URL

You are right, sorry, but that's because something happened copying th eURL here and there, I checked it and it look OK in the Emerald action. Infcat even the URLs down here look wrong, but if I edit th epost they look just fine. like this: https://www.facebook.com/tr?id=497135833810934& ;ev=PageView&noscript=1

Something happens when I save the post or its' the code block style, couldn't say

SO I did some more tests after your explanation and here are the results:

TEST 1

Javascript field EMPTY

HTML field with this code

<script src="/ https://www.facebook.com/tr?id=497135833810934& ;ev=PageView&noscript=1"> </script>
<script>
  fbq('track', 'Purchase', {
    value: 10,
    currency: 'EUR',
  });
</script>

result: Purchase is NOT being registered by Facebook

TEST 2

Javascript field EMPTY

HTML field with this code

<noscript><img height="1" width="1" style="display:none"
  src="/ https://www.facebook.com/tr?id=497135833810934& ;ev=PageView&noscript=1"
/></noscript>
<script>
  fbq('track', 'Purchase', {
    value: 10,
    currency: 'EUR',
  });
</script>

result: Purchase is NOT being registered by Facebook

TEST 3

Javascript field EMPTY

HTML field with this 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', '497135833810934');
  fbq('track', 'PageView');
  fbq('track', 'Purchase',{value: 10,currency: 'EUR',});
</script>
<noscript><img height="1" width="1" style="display:none"
  src="/ https://www.facebook.com/tr?id=497135833810934& ;ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->

result:

Purchase is registered succesfully but there is another issue: a new purchase is being registered every time I edit the Subscription Plan, because apparently the code loads there as well...

fb-purchase

If I understand correctly the Facebook pixel code I inserted in my template by default is not being loaded by Emerald upon purchase, this is way a purchase is being registered only if I insert the FULL facebook pixel code in the Emerald action, but this way every time I edit the plan in Emerald a new pucrhase is also registered...

I don't know Sergey, I think you should really test this on your side and verify if there is a way to get it working, facebook pixel actions are really important for facebook marketing.

Thank you


Sergey
Total posts: 13,748
18 Apr 2018 08:29

I looked at code. And it is impossible. There is only one place this code is called and it is when subscription successfuly purchased and only when subscriber of subscription is logged in. I do not know how that happened. May be you made publish and unpublish of subscription, but even then it should not happen.


nican VIP
Total posts: 392
19 Apr 2018 11:12

If I look at Facebook logs it happens when I save the subscription after inserting the code. I understand this may be frustrating for you, but still I think that the only way to really solve it is for you to test on your side. With that being said, I also understand if you dont' have the time/will to do it, there must not be many serious facebook marketers using emerald since nobody seems to have brought up this issue.

Thanks


nican VIP
Total posts: 392
19 Apr 2018 14:13

I did some more testing, I update this post in case someone is strugling with a similar issue. by inserting in Emerald Javascript action the whole facebook pixel code (in my case adding to it a "Purchase" action),like this

<!-- 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', '497135833810934');
  fbq('track', 'PageView');
  fbq('track', 'Purchase',{value: 10,currency: 'EUR',});
</script>
<noscript><img height="1" width="1" style="display:none"
  src="/ https://www.facebook.com/tr?id=497135833810934& ;ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->

I was able to get the action registered upon subscription purchase, but with several issues

issue 1: the action does not register every time, on average 50% of the times

issue 2: whenever the action is registered (meaning the fb code is being actually loaded), instead of being redirected to the correct url after purchase I see this (if i refresh manually the page, then I am redirected to the correct page)

issue-fb-pixel

issue 3: the action is being apparently registered also when I edit the subscription, in FB log I see the URL https://mysite.com/emerald?view=emplan& ;layout=edit&id=13 as the url where the action is being registered, that is the emerald plan edit url. Still, could be a facebook issue and maybe those registrations of the action have happened upon real purchase instead, couldnt' really say and it would need more testing.


Sergey
Total posts: 13,748
19 Apr 2018 15:46

nican issue 1: the action does not register every time, on average 50% of the times

this is not reeally reliable technology. I mean not Emerald but JS as analytics pзшслукюthat is becuse user might close page soone than all page was loaded. Theer might be another JS error on the page that breack JS execution and that code might fail. There might be conflicts with other JS scripts. I mean even if you hardcode something to place this code upon success purchase, it would not work much better.

nican issue 2: whenever the action is registered (meaning the fb code is being actually loaded), instead of being redirected to the correct url after purchase I see this (if i refresh manually the page, then I am redirected to the correct page)

To solve this, would be mice to turn off SEF that I could see what an URL it is. What view and layout. Also change encoding of this page to UTF 8 and see if you see first simbols that can say what object it is. Looks like binary file.> nican

issue 3: the action is being apparently registered also when I edit the subscription, in FB log I see the URL https://mysite.com/emerald?view=emplan& ; ;layout=edit&id=13 as the url where the action is being registered,

that is interesting. Maybe when you edit action and it is loaded, and it interprites what is in textarea as real HTML. That is strange. But possible.

I think it is minor problem Once you set everything up, yu will not have to edit your plan very often.

Powered by Cobalt