Tagged: x
-
AuthorPosts
-
December 24, 2016 at 3:25 am #1303455
Kamila LParticipantHi All,
I added the facebook pixel to the child theme php but facebook isnt recognizing it. Could you please take a look and advise how to fix it?
Thanks,
-KDecember 24, 2016 at 3:38 am #1303460
ChristopherModeratorHi there,
Please share the code and let us know how did you implement it?
Thanks.
December 24, 2016 at 4:48 pm #1303669
Kamila LParticipantThis reply has been marked as private.December 25, 2016 at 4:34 am #1303890
ChristopherModeratorHi there,
Please update your code to :
// Add Facebook custom pixel Code // ============================================================================= function add_facebook_pixel_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', '582376465296693'); // Insert your pixel ID here. fbq('track', 'PageView'); fbq('track', 'Lead', { value: 10.00, currency: 'USD' }); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=582376465296693&ev=PageView&noscript=1" /></noscript> <!– DO NOT MODIFY –> <!– End Facebook Pixel Code –> <?php } add_action( 'wp_head', 'add_facebook_pixel_code' ); // End Facebook custom pixel Code // =========================================================Hope it helps.
December 25, 2016 at 10:41 pm #1304282
Kamila LParticipantHi Christopher,
Thanks for the above. So I want a lead conversion pixel on my thankyou page (589) and tracking pixel on page (481).
The code on the thankyou page isnt working. How would I fix this? See my code below.
Thanks,
add_action( ‘x_before_site_begin’, ‘facebook_pixel_code’ );
function facebook_pixel_code(){
if(is_page(481) ) : ?>
<!– 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’, ‘582376465296693’); // Insert your pixel ID here.
fbq(‘track’, ‘PageView’);
</script>
<noscript><img height=”1″ width=”1″ style=”display:none”
src=”https://www.facebook.com/tr?id=582376465296693&ev=PageView&noscript=1″
/></noscript>
<!– DO NOT MODIFY –>
<!– End Facebook Pixel Code –>
add_action( ‘x_before_site_begin’, ‘facebook_pixel_code’ );
function facebook_pixel_code(){
if(is_page(589) ) : ?>
<!– 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’, ‘582376465296693’); // Insert your pixel ID here.
fbq(‘track’, ‘Lead’, {
value: 10.00,
currency: ‘USD’
});
</script>
<noscript><img height=”1″ width=”1″ style=”display:none”
src=”https://www.facebook.com/tr?id=582376465296693&ev=PageView&noscript=1″
/></noscript>
<!– DO NOT MODIFY –>
<!– End Facebook Pixel Code –>
<?php
endif; }
Thanks,
-KDecember 25, 2016 at 11:24 pm #1304295
Rue NelModeratorHello There,
Thanks for updating in! If you want to display the code only for a specific page, you need to add a condition in the code. Please have your code updated and use this code instead:
// Add Facebook custom pixel Code // ============================================================================= function add_facebook_pixel_code(){ ?> <?php if ( is_page(589) || is_page(481) ) : ?> <!– Facebook Pixel Code –> add the code here <!– End Facebook Pixel Code –> <?php endif; ?> <?php } add_action( 'wp_head', 'add_facebook_pixel_code' ); // End Facebook custom pixel Code // =========================================================We would loved to know if this has work for you. Thank you.
December 26, 2016 at 11:10 pm #1305236
Kamila LParticipantHi Rue,
Thanks for the above so I want the lead tracking for only page 589 – fbq(‘track’, ‘Lead’, {
value: 10.00,
currency: ‘USD
and I want the regular conversion tracking for only page 481.
How would i separate the code out to account for different tracking for different pages? Hopefully this a bit clearer.
Thanks,
KamilaDecember 26, 2016 at 11:25 pm #1305245
FriechModeratorHi Kamila,
You can remove the bit of line below on Rue’s code so it will only apply to page 589.
|| is_page(481)But I assume you already know that, can you confirm that your “thank you” page has an ID of 589? If so, provide us login credentials in private reply so we can take a closer look.
Cheers!
December 26, 2016 at 11:46 pm #1305304
Kamila LParticipantThis reply has been marked as private.December 27, 2016 at 12:09 am #1305321
LelyModeratorHello K,
The following line might has been remove from your child theme functions.php file:
add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );
Default content should be like this:<?php // ============================================================================= // FUNCTIONS.PHP // ----------------------------------------------------------------------------- // Overwrite or add your own custom functions to X in this file. // ============================================================================= // ============================================================================= // TABLE OF CONTENTS // ----------------------------------------------------------------------------- // 01. Enqueue Parent Stylesheet // 02. Additional Functions // ============================================================================= // Enqueue Parent Stylesheet // ============================================================================= add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );Then add the code suggested for pixel below the last line.
Hope this helps.
December 27, 2016 at 3:04 pm #1306233
Kamila LParticipantHi Lely/Friech,
Thanks that resolved the formatting issue. Can you advise on how I can put the lead tracking on page 589 only?
fbq(‘track’, ‘Lead’, {
value: 10.00,
currency: ‘USD
and Apply the base FB code to page 481 only?
Thanks!
-KDecember 27, 2016 at 6:42 pm #1306401
FriechModeratorHi Kamila,
Unfortunately that is not possible, the base pixel should be fire first or else any events code (tracking) will not work.
Use this code to place the base code on every page.
// Add Facebook custom pixel Code // ============================================================================= function add_facebook_pixel_code(){ ?> <!-- PASTE YOUR BASE PIXEL CODE HERE --> <?php } add_action( 'wp_head', 'add_facebook_pixel_code', 10 ); // End Facebook custom pixel Code // =========================================================Replace the phrase <!– PASTE YOUR BASE PIXEL CODE HERE –> with your actual base code.
Make sure there is no tracking code on the base pixel code or else it will be added on every page as well.And now to add the lead tracking code on page 589 only, add this code on your child theme functions.php file.
function add_lead_tracking_code(){ ?> <?php if ( is_page(589) ) : ?> <script type="text/javascript"> fbq('track', 'Purchase', {value: '10.00', currency:'USD'}); </script> <?php endif; ?> <?php } add_action( 'wp_head', 'add_lead_tracking_code', 20 );Again, the tracking code will not work if there is no pixel base code above it. You can read more details about Facebook Pixel Implementation here.
Hope it helps, Cheers!
December 27, 2016 at 9:23 pm #1306627
Kamila LParticipantThank You!! You guys are amazing. That worked 🙂
December 27, 2016 at 10:01 pm #1306654
FriechModeratorGlad we could help 🙂
Happy New Year, Cheers!
December 27, 2016 at 11:46 pm #1306729
Kamila LParticipantHi Friech,
So after a I updated the php my wordpress went blank. I am unable to access the wp-admin page. I deleted all the fb pixel code via filezilla however I am unable to access the site.
Help Please!!
Thanks,
-K -
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1303455 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
