Custom JavaScript and Pixel Tracking
You can run custom JavaScript code on a survey, such as loading a pixel for tracking purposes. This can be applied to both Study Screeners and Panel Sign-up forms.
Important notes
- The code will execute right after the page loads.
- If you run JavaScript code, you need to include <script> tags.
Adding JavaScript code
To add custom Javascript or Pixel Tracking to your Panelfox screeners:
- Go to the Screener > Screener Settings or Panel Sign-up > Form Settings page
- Scroll down to the Custom HTML section of the page, and add your code.
- To test this code, go to the Screener Builder tab, and click Preview at the top of the page.
- On the new Preview tab, you can open up Developer Tools > Console to inspect code execution.
- To verify that your code started executing, you'll see:
- If there is an error in your code, you'll see something like this:
- To verify that your code started executing, you'll see:
Examples loading a script or pixel
To load a script like Google Tag Manager, your code will look something like this:
<!-- Google Tag Manager --> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-XXXXXX');</script> <!-- End Google Tag Manager -->
To load the Facebook pixel:
<!-- 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', '<FB_PIXEL_ID>'); fbq('track', "PageView"); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=<FB_PIXEL_ID>&ev=PageView&noscript=1" /></noscript> <!-- End Facebook Pixel Code -->