- This topic has 6 replies, 3 voices, and was last updated 7 years, 2 months ago by Tom.
-
AuthorPosts
-
September 22, 2017 at 4:13 pm #390274Dave
Hi Tom,
I have the following FB Pixel that is supposed to appear on every page so I put it in the wp_head hook. Here is that 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’, ‘172080303350186’);
fbq(‘track’, ‘PageView’);
</script>
<noscript><img height=”1″ width=”1″ style=”display:none”
src=”https://www.facebook.com/tr?id=172080303350186&ev=PageView&noscript=1″;
/></noscript><!– End Facebook Pixel Code –>
———————————————
Now I’m supposed to put a Facebook Pixel Code on the Landing page that I built to show that the content was viewed. Here is that 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’, ‘172080303350186’);
fbq(‘track’, ‘PageView’);fbq(‘track’, ‘ViewContent’);
</script>
<noscript><img height=”1″ width=”1″ style=”display:none”
src=”https://www.facebook.com/tr?id=172080303350186&ev=PageView&noscript=1″;
/></noscript>
<!– End Facebook Pixel Code –>
———————————————
The only change is the insertion of this code – fbq(‘track’, ‘ViewContent’); –I’m also supposed to insert the pixel again on the ‘Thank You’ page that I built so that I can tell if the conversion took place. In this case I replace the – fbq(‘track’, ‘ViewContent’);- with – fbq(‘track’, ‘Lead’); –
So these fire individually on each page. Do you have any idea where I should put the second two scripts?
I don’t know if the go below the first script in the wp_head tag or in one of the other hooks.
Thanks for you help!
September 22, 2017 at 10:04 pm #390342LeoStaffCustomer SupportHi there,
Yup that can all go into
wp_head
We will need to wrap them in conditional tags so they are only on certain pages though.
For front page:
<?php if ( is_front_page() ) : ?> code here <?php endif; ?>
For thank you page:
<?php if ( is_page( 'your-page' ) ) { ?> code here <?php } ?>
Make sure execute PHP is checked.
September 22, 2017 at 11:20 pm #390362TomLead DeveloperLead DeveloperShould work perfectly.
You can confirm the pixel is working by following the instructions on this page: https://www.facebook.com/business/help/952192354843755
#4 – Make sure your pixel’s working correctly
September 23, 2017 at 8:18 am #390582DaveHi Tom & Leo,
I’m really struggling with this. Here is the code I inserted in the wp_head hook, and clicked the box to Execute PHP
Here is the complete script copied directly from wp_head:
<!– 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’, ‘172080303350186’);
fbq(‘track’, ‘PageView’);
</script>
<noscript>
<img height=”1″ width=”1″
src=”https://www.facebook.com/tr?id=172080303350186&ev=PageView
&noscript=1″/>
</noscript>
<!– End Facebook Pixel Code –><?php if ( is_front_page() ) : ?>
<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’, ‘172080303350186’);
fbq(‘track’, ‘PageView’);
fbq(‘track’, ‘ViewContent’);
</script>
<noscript><img height=”1″ width=”1″ style=”display:none”
src=”https://www.facebook.com/tr?id=172080303350186&ev=PageView&noscript=1″;;
/></noscript>
<!– End Facebook Pixel Code –>
<?php endif; ?><?php if ( is_page( ‘thank-you’ ) ) { ?>
<!– 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’, ‘172080303350186’);
fbq(‘track’, ‘PageView’);
fbq(‘track’, ‘Lead’);
</script>
<noscript><img height=”1″ width=”1″ style=”display:none”
src=”https://www.facebook.com/tr?id=172080303350186&ev=PageView&noscript=1″;;
/></noscript>
<!– End Facebook Pixel Code –>
<?php } ?>When I check it with the Chrome pixel helper, the first ‘Pageview’ code fires. However the conditional pixels for (is_front_page() and ( is_page( ‘thank-you’ ) ), gives me this error.
-The Facebook pixel code on this page didn’t load, therefore no information was sent to facebook –
I’m pretty sure I followed the instructions as described but I can’t seem to isolate the problem.
The URL’s are:
https://www.bestlocalroofing.com/
https://www.bestlocalroofing.com/thank-you/
I don’t know if you can test on your end or see anything, I can also give you a login to the site. I am using Thrive Architect to build these, but I don’t think that should matter for this.
Any help is appreciated!
Dave ~
September 23, 2017 at 7:37 pm #390798TomLead DeveloperLead DeveloperHi Dave,
Are you trying a different method now? Your code looks different than what you shared in here earlier.
Let me know ๐
September 23, 2017 at 8:32 pm #390809DaveTom,
Sorry. I think that there’s a conflict with Thrive Architect which is a page builder for developing sales funnels. It’s the WordPress alternative to ClickFunnels which I absolutely hate. I’m using Thrive Architect on this particular project with your theme. From what I can tell from their documentation, if you use it to building a landing page their custom script area settings on the landing page nullifies wp_head code in the theme script for that page.
I don’t know for sure as their support is very slow. I ended up using:
https://wordpress.org/plugins/pixel-caffeine/
It’s a free plugin and I was done in 5 minutes after trying to figure out where the problem was for hours. I should have updated this ticket so you guys didn’t spend more time on it. I’ll eventually get an answer from their support, but this was the solution for me right now as I needed to get a Facebook ad campaign going for a client.
Thanks for a great product and great support.
Dave ~
September 23, 2017 at 10:49 pm #390842TomLead DeveloperLead DeveloperNo problem! Glad you got something working for now ๐
-
AuthorPosts
- You must be logged in to reply to this topic.