Tagged: x
-
AuthorPosts
-
March 3, 2017 at 5:33 am #1393163
Hi,
I need to add three different pixel codes to my site: Facebook, Google and MediaMath.
I’m running a child theme, and I’ve read a couple of threads on how to do this, but how do you add three different pixel codes?
I also read that you can use the Google Analytics extension, but this only seemed to work for one script. Adding another script generated an error – I could see the text of the script rendered above the header.
Many thanks!
March 3, 2017 at 11:05 am #1393513Hi there,
Thanks for writing in! Regretfully, at this time I am not entirely certain what it is you would like to accomplish based on the information given in your post. If you wouldn’t mind providing us with a little more clarification on what it is you’re wanting to do (a link to a similar example site would be very helpful, or perhaps some screenshots), we’ll be happy to provide you with a response once we have a better understanding of the situation.
March 3, 2017 at 11:20 am #1393527Facebook and google pixels are 1×1 gifs inserted using js code for tracking purposes. For example, the Facebook custom audience pixel code looks 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', 'XXXXXXXXXXXXXXX'); fbq('track', 'PageView'); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=XXXXXXXXXXXXXXX&ev=PageView&noscript=1" /></noscript> <!– End Facebook Pixel Code –>
There’s a thread that talks about adding Facebook pixel code to the functions.php of a child theme, so I figured out how to do that. However, I also have a google ads tracking pixel, and a MediaMath tracking pixel. I’m unsure how to add these to the functions.php (the code is in the private reply below).
March 3, 2017 at 11:23 am #1393530This reply has been marked as private.March 3, 2017 at 11:26 am #1393539This reply has been marked as private.March 3, 2017 at 1:32 pm #1393679Hi there,
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
March 3, 2017 at 3:47 pm #1393800This reply has been marked as private.March 4, 2017 at 1:43 am #1394197Hello There,
Thanks for updating in! To add the code in your child theme’s functions.php file, you can insert the following code:
// Custom Pixel Code // ============================================================================= function add_custom_pixel_code(){ ?> <!-- Google Code for Wipers Times 17 --> <!-- Google Code for Remarketing Tag --> <!-------------------------------------------------- Remarketing tags may not be associated with personally identifiable information or placed on pages related to sensitive categories. See more information and instructions on how to setup the tag on: http://google.com/ads/remarketingsetup ---------------------------------------------------> <script type="text/javascript"> /* <![CDATA[ */ var google_conversion_id = 858993994; var google_conversion_label = "-M8yCI-i9G4QyurMmQM"; var google_custom_params = window.google_tag_params; var google_remarketing_only = true; /* ]]> */ </script> <script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"> </script> <noscript> <div style="display:inline;"> <img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/858993994/?value=1.00¤cy_code=GBP&label=-M8yCI-i9G4QyurMmQM&guid=ON&script=0"/> </div> </noscript> <script language='JavaScript1.1' src='//pixel.mathtag.com/event/js?mt_id=1138712&mt_adid=182989&v1=&v2=&v3=&s1=&s2=&s3='></script> <?php } add_action('wp_head', 'add_custom_pixel_code'); // =============================================================================
Please let us know if this works out for you.
March 4, 2017 at 1:51 am #1394201Hi,
Thanks for your reply.
Google instructions are to place the remarketing code at the bottom of the page, before the closing </body> tag. It looks like the above code places it in the <head>.
How would I revise your code to meet the Google guidelines?
March 4, 2017 at 2:38 am #1394222Hi,
I changed
add_action('wp_head', 'add_custom_pixel_code');
to
add_action('wp_footer', 'add_custom_pixel_code');
However, the remarketing code is not working – no 1×1 gif can be seen in the images resource of the source code. The facebook pixel is working, but as far as I can tell no remarketing analytics.
March 4, 2017 at 3:22 am #1394244I’ve made some changes, and I believe I have it working now. Thanks for your help, and I will update if I have any further issues.
March 4, 2017 at 3:51 am #1394264Glad you sorted things out, feel free to get in touch with us regarding any further queries about the X|Theme and Cornerstone.
Cheers!
-
AuthorPosts