Black Friday Up to 50% off every Pro plan. Annual from $24.50, Lifetime from $51.Up to 50% off ProAgency Bundle $449 $1,499 Agency Bundle$1,499 $449 Ends in Getthe deal
Site tool · Free

Elementor Code Snippets: add header and footer code

Code snippets for Elementor: 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.

Each demo pairs the wp-admin settings with what the site does. Change a setting to see the effect. All five are free in Animation Addons.

01

Analytics tag loaded on every page

Nothing changes on screen; the tag loads in the page head. Set Code Type to JavaScript, Load Location to Head Section and Where should this snippet appear? to Entire Website. Paste the script's code only, without the script tags, because Animation Addons wraps it. Change Load Location to see the tag move.

02

Search Console and social preview tags

The site verifies in Search Console and shared links show the right image. Set Code Type to HTML (meta tags are allowed), Load Location to Head Section and Where should this snippet appear? to Front Page. Keep one snippet per service. Open the pricing page to see the tags are not there.

03

Holiday sale styles on the shop only

Red and cream sale badges and buttons on the shop page, and nothing on the journal. Set Code Type to CSS, Load Location to Head Section and Where should this snippet appear? to Products Archive (the WooCommerce shop is the product archive). Switch the snippet off with Enable or disable this snippet on the last day. The CSS stays saved for next year.

04

Booking widget on two landing pages

The booking tool loads only on the Book a visit and New patients pages. Set Code Type to JavaScript, Load Location to Footer, Where should this snippet appear? to Specific Pages / Posts. and choose both pages in Add Specific Pages. Footer placement lets the page render before the third-party script. Untick a page to see the widget leave.

05

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. Set Code Type to CSS with an @media print rule, Load Location to Head Section and Where should this snippet appear? to the Case Studies Singulars option. Keep 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. That keeps your Elementor header and footer scripts in one list.

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

Add WordPress code snippets in Elementor

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

Try Animation Addons
  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, which covers Elementor custom 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 header and footer code?

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

How do I add analytics code?

To add analytics code to WordPress on an Elementor site, use a JavaScript snippet in Animation Addons Code Snippet. Paste only the script's code, without the opening and closing script tags, set Load Location to Head Section and Where should this snippet appear? to Entire Website. Animation Addons wraps the code in script tags for you.

Is it a header and footer plugin?

Yes. Code Snippet is an insert headers and footers alternative for sites that already run Animation Addons. It holds CSS, JavaScript and HTML in one list, offers five load locations, applies page rules, and gives each snippet its own on/off switch. It works with Elementor Free and Pro.

How do I add a script to one page?

To add a script to one page in WordPress, set "Where should this snippet appear?" to Specific Pages / Posts. in Animation Addons Code Snippet and pick the page in Add Specific Pages. Choose the Load Location, usually Footer for third-party widgets, and save. The script then loads only on that page.

Why did my script tag vanish?

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. For tags with both a script and a noscript part, use the JavaScript part.

Are PHP snippets included for free?

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, because a PHP mistake can take a site down.

Does it work with any theme?

Yes. Animation Addons Code Snippet works with Elementor Free and Pro and any theme, so your Elementor code snippets are not tied to one 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 tags a vendor says must load early, use Head Section.

Can I turn a snippet off?

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.

How do I add a verification tag?

To add a site verification meta tag in WordPress, use an HTML snippet. Set Code Type to HTML, paste the meta tag the service gave you, set Load Location to Head Section and choose Front Page under "Where should this snippet appear?". HTML snippets allow meta tags, so nothing is stripped.

Can I load CSS on specific pages only?

Yes. You can load CSS on specific pages by creating a CSS snippet and choosing a rule under "Where should this snippet appear?", such as Products Archive for a WooCommerce shop, a post type's Singulars, or Specific Pages / Posts. The styles then load only there, and nowhere else on the site.

More answers in the FAQ · Documentation · Free vs Pro

Animation Addons Pro · Elementor 4

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.

Black Friday dealup to 50% off every Pro planEnds 10 Dec

  • 15-day money-back guarantee
  • Rated 4.6 / 5 on WordPress.org
  • No Elementor Pro needed
  • Elementor 3 & 4 in one license