Add code snippets to your website (GA4, GTM, Meta Pixel)
Add analytics code, tracking pixels or custom JavaScript to your Learnyst site from Integrations > Code Snippets, then check that it works.
Code Snippets let you add third-party code to your Learnyst site, such as the Google tag for Google Analytics 4, a Google Tag Manager container, the Meta Pixel or a chat widget. You paste the code once and save it.
Before you start
- Custom code is included in every Learnyst plan. See learnyst.com/pricing.
- Copy the code from the tool you are adding. Paste only code from tools you trust, because it runs on your site.
The Code Snippets page
The page is called Code Snippets (Analytics Tracking Code & Custom Javascript Code) and has four tabs:
- Site Footer Code: for analytics code, tracking pixels or custom JS for your site. This is the tab to use for a Google tag, GTM container or Meta Pixel base code.
- Site Body Code
- Signup Tracking Code: for code a tool gives you specifically for sign-ups.
- Order Tracking Code: for code a tool gives you specifically for orders (purchases).

Add a code snippet
- Go to Grow > Marketing > Integrations. The App Integrations page opens.
- Click Code Snippets.
- Open the Site Footer Code tab (or the tab that matches your code).
- Paste your code into the box (Copy & paste your code here). As the page says, wrap the code in a
<script>tag. - Click Save changes. Click Cancel to leave without saving.

As the page notes, please check that your scripts work properly after you save them.
Sample code you can copy
These are the standard snippets from Google and Meta. Copy one, replace the ID in it with your own, and paste it into the tab shown.
Google Analytics 4 (Google tag): paste into Site Footer Code. Replace both G-XXXXXXXXXX with your Measurement ID (in Google Analytics: Admin > Data streams > your web stream).
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
Meta Pixel base code: paste into Site Footer Code. Replace both YOUR_PIXEL_ID with your Pixel ID (in Meta Events Manager, under your dataset or pixel).
<!-- Meta 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', 'YOUR_PIXEL_ID');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=YOUR_PIXEL_ID&ev=PageView&noscript=1"/></noscript>
<!-- End Meta Pixel Code -->
Sign-up event: paste into Signup Tracking Code. It works only when the base code above is already in Site Footer Code.
<script>
// Meta Pixel: count a completed sign-up
if (window.fbq) { fbq('track', 'CompleteRegistration'); }
// Google Analytics 4: count a sign-up
if (window.gtag) { gtag('event', 'sign_up'); }
</script>
Purchase event: paste into Order Tracking Code. It records that a purchase happened. It does not send the actual order amount, so use your ad or analytics reports for counts, and your Learnyst sales reports for revenue.
<script>
// Meta Pixel: count a purchase (replace 0 and INR only if you send a fixed value)
if (window.fbq) { fbq('track', 'Purchase', {value: 0, currency: 'INR'}); }
// Google Analytics 4: count a purchase
if (window.gtag) { gtag('event', 'purchase', {currency: 'INR'}); }
</script>
Add each base code only once. If you use Google Tag Manager, add GA4 and the Meta Pixel inside GTM instead of pasting them here, or visits are counted twice.
Check that it works
- Open your school website in a private browser window with ad blockers turned off.
- Use the tool's own checker, for example Google Tag Assistant for Google tags, or the Meta Pixel Helper or Test Events in Meta Events Manager for the Meta Pixel.
For a full checklist, see Is my Meta Pixel or GA4 working?
Use cases
- Coaching institute running Meta ads: add the Meta Pixel to measure visits from your Facebook and Instagram ads.
- Any school: add Google Analytics 4 to see where your visitors come from.
- Several tools: add one Google Tag Manager container and manage all your tags inside GTM.
Best practices
- Don't add the same tag twice, for example GA4 directly and again inside GTM. Visits are then counted twice.
- Keep a note of what you pasted and when, so you can find and remove it later.
If it doesn't work
- The tag isn't found: check that you clicked Save changes, that the code is wrapped in a
<script>tag, and test again in a private window. - Old code still runs: clear it from every tab, click Save changes and test in a new private window. If you use GTM, also pause or remove the tag inside your GTM container.
- Only Google Analytics needed: you can also use the Google Analytics integration. See Add Google Analytics to your Learnyst website.
What to do next
- Add Google Analytics to your Learnyst website
- Track sign-ups and purchases with the Meta Pixel
- Is my Meta Pixel or GA4 working?
If you have questions, contact us at support@learnyst.com.