V4 Early Bird: save 25% on Annual, 30% on Lifetime, and get 2x site activations on every plan. Ends Oct 17.V4 Early Bird: up to 30% off + 2x sites · ends Oct 17. See plans →
Site tool · Free

WordPress Code Snippets for Elementor: add header and footer code with page rules

Add analytics, verification tags, CSS and small scripts to the head, body or footer of your Elementor site, on every page or only the ones you pick. Free, from one wp-admin screen, with an on/off switch per snippet.

  • Free: CSS, JavaScript, HTML
  • 5 load locations
  • Page and post-type rules
  • PHP snippets in Pro

Animation Addons 4.3Updated

Demo variations

Five ways to use Code Snippet.

Ideas you can build today with Code Snippet, free in Animation Addons, on Elementor 4's own elements. The settings on each card are a good place to start.

01Any business site that needs privacy-friendly analytics on day one

Analytics tag on every page

Nothing changes visually; the analytics script loads in the head of every page.

Built with
Code Type JavaScript; Load Location Head Section; Where should this snippet appear? Entire Website.
Start with
Paste the script's code only, without the opening and closing script tags; Animation Addons wraps it for you.
02New sites that need ownership verification and a default social preview

Search Console and social meta tags

Meta tags in the page head; the site verifies and links show the right preview image.

Built with
Code Type HTML (meta tags are allowed); Load Location Head Section; Where should this snippet appear? Front Page.
Start with
One snippet per service.
03WooCommerce stores running a seasonal promotion

Holiday banner styles on the shop only

Red-and-cream sale badges and buttons on the shop page only, switched off in one click after the sale.

Built with
Code Type CSS; Load Location Head Section; Where should this snippet appear? Products Archive (the WooCommerce shop is the product archive).
Start with
Turn the snippet's status off on the last day; the CSS stays saved for next year.
04Clinics and studios using a third-party booking tool on selected pages

Booking widget on two landing pages

The booking tool's script loads only on the "Book a visit" and "New patients" pages; other pages stay lighter.

Built with
Code Type JavaScript; Load Location Footer; Where should this snippet appear? Specific Pages / Posts. with both pages chosen in Add Specific Pages.
Start with
Footer placement lets the page content render before the third-party script.
05Agencies whose prospects print or save case studies as PDF for a buying committee

Print-friendly case studies

On screen nothing changes; when printed, the header, footer and cookie bar drop away and the case study fills the page.

Built with
Code Type CSS (an @media print rule); Load Location Head Section; Where should this snippet appear? the "Case Studies Singulars" option (any public post type, including ones made with Post Type Builder, gets Archive and Singulars options).
Start with
One snippet per post type, titled after it.
Features

What you get with Code Snippet.

Every point below is a real control in the Code Snippet screen or part of how it works. Nothing here needs custom code.

Five places to put code

Load Location offers Head Section, After Body Open, Before Content, After Content and Footer, so a tag manager's body part, a script and its styles each go where the vendor asks.

Page rules without writing conditions

Where should this snippet appear? groups its options: Basic (Entire Website, All Singulars, All Archives), Special Pages (404, Search, Blog / Posts Page, Front Page, Date Archive, Author Archive), each public post type's Archive and Singulars (including WooCommerce Products), and Specific Pages / Posts.

One switch per snippet

Each snippet has an on/off switch, plus a Status toggle and bulk Activate and Deactivate in the list.

Safe by default

Only administrators can create snippets, and HTML snippets are filtered to safe HTML plus style, meta and link tags.

PHP snippets with Pro

Animation Addons Pro adds PHP as a Code Type. PHP snippets also need a user who can edit plugins, and they stay off on sites that disable file editing in wp-config.php (DISALLOW_FILE_EDIT or DISALLOW_FILE_MODS).

Step by step

How to add WordPress code snippets to the header and footer in Elementor

Five steps from switching it on to publishing. The bold names are the exact labels you will see on screen.

Download free
  1. In wp-admin, switch on Code Snippet under the Extensions tab of the Animation Addon dashboard.

  2. Open Animation Addon > Code Snippet and click Add New Snippet.

  3. Enter a Snippet Title, choose the Code Type (HTML, CSS or JavaScript) and paste your code.

  4. Choose a Load Location, then pick the pages under Where should this snippet appear? (choose Specific Pages / Posts. to list pages in Add Specific Pages).

  5. Turn on Enable or disable this snippet and click Save Snippet. Load the page in a private window and check the source.

Who it's for

Who uses Code Snippet?

The people who get the most out of it, and what they use it for.

  • Freelancers on Elementor Free

    Adding analytics and verification tags for clients.

  • Agencies

    That want every client's scripts in one list with on/off switches instead of in theme files.

  • Store owners

    Loading campaign CSS or tracking only on shop pages.

FAQ

Questions about Code Snippet

How do I add code to the header of an Elementor site without a plugin like Insert Headers and Footers?

If you already use Animation Addons for Elementor, switch on its Code Snippet extension. Add a new snippet, pick Code Type, set Load Location to Head Section, choose Entire Website under "Where should this snippet appear?", turn it on and save. Animation Addons prints the code in every page's head, and it survives theme updates.

Can I add PHP snippets with the free Animation Addons plugin?

No. The free Animation Addons Code Snippet extension runs CSS, JavaScript and HTML. PHP snippets need Animation Addons Pro, a user allowed to edit plugins, and a site where file editing has not been disabled in wp-config.php. That gate is deliberate: a PHP mistake can take a site down, so it sits behind stricter permissions.

Why did my script tag disappear from an HTML snippet?

Animation Addons Code Snippet filters HTML snippets to safe HTML plus style, meta and link tags, so script tags are removed. Put scripts in a JavaScript snippet instead and paste only the code inside the script tags. Animation Addons adds the script tag for you. For tags with both a script and a noscript part, use the JavaScript part.

How do I add a script to one specific page in WordPress?

In Animation Addons Code Snippet, set "Where should this snippet appear?" to Specific Pages / Posts. and pick the pages in Add Specific Pages. Choose the Load Location, usually Footer for third-party widgets, and save. The Animation Addons snippet then loads only on those pages, which keeps the rest of the site lighter.

Does Code Snippet work with Elementor Free and any theme?

Yes. Animation Addons Code Snippet works with Elementor Free and Pro and any theme. Head Section and Footer use the standard WordPress head and footer hooks that themes call. After Body Open needs a theme that supports wp_body_open, which most current themes do. For anything a vendor says must load early, use Head Section.

Can I turn a snippet off without deleting it?

Yes. Every Animation Addons Code Snippet has an on/off switch on its edit screen and a Status toggle in the snippet list, plus bulk Activate and Deactivate. An inactive snippet keeps its code and settings, so seasonal styles or campaign tags can be switched back on next time.

More answers in the FAQ · Documentation · Free vs Pro

Take the tracking tags out of your theme files.

Free in Animation Addons for Elementor: five load locations, page rules and one switch per snippet. PHP snippets come with Pro.

  • Free on WordPress.orgNo Elementor Pro needed
  • Part of the free pluginSwitch it on in the Extensions screen
  • Animation Addons 4.3Updated October 2026