Back to Shopify Liquid
Facebook views
Shopify Liquid

Facebook views

Displays an animated social proof badge highlighting Facebook video views or reach. The snippet uses a CSS-animated gradient border and a fixed text overlay to build trust and authority with visitors.

EasyTrustSocial Proof BadgeFacebookCROProduct Page
82 lines · 1.7 KB
Setup 5–10 minutes 4 min read 81 lines
Key features
  • Animated CSS gradient border effects
  • Responsive centered flexbox layout
  • Localized CSS scoping with unique class naming
  • No external dependencies or scripts required
Best use cases
  • Increasing conversion rates on high-traffic landing pages.
  • Highlighting viral social media peaks on product detail pages.
  • Adding dynamic social proof to the footer or sidebar areas.
Compatibility
  • Most Shopify themes

The code

Shopify Liquid
1<!DOCTYPE html>
2<html lang="en">
3<head>
4<meta charset="UTF-8">
5<meta name="viewport" content="width=device-width, initial-scale=1.0">
6<title>Facebook Badge</title>
7<style>
8 body.unique-body-Qwe123 {
9 display: flex;
10 justify-content: center;
11 align-items: center;
12 height: 100vh;
13 margin: 0;
14 background-color: #fff;
15 }
16
17 .unique-facebook-badge-Rty456 {
18 display: flex;
19 align-items: center;
20 justify-content: center;
21 background: linear-gradient(45deg, #4267B2, #3b5998);
22 border-radius: 7px;
23 color: #fff;
24 font-size: 14px;
25 font-weight: bold;
26 padding: 5px 20px;
27 text-decoration: none;
28 box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
29 border: 3px solid transparent;
30 background-clip: padding-box;
31 position: relative;
32 height: 35px;
33 width: 100%;
34 max-width: 300px;
35 text-align: center;
36 }
37
38 .unique-facebook-badge-Rty456::before {
39 content: '';
40 position: absolute;
41 top: -3px;
42 left: -3px;
43 right: -3px;
44 bottom: -3px;
45 border-radius: 7px;
46 background: linear-gradient(45deg, #4267B2, #3b5998);
47 background-size: 200% 200%;
48 animation: unique-gradient-animation-Uio789 3s linear infinite;
49 z-index: -1;
50 }
51
52 @keyframes unique-gradient-animation-Uio789 {
53 0% {
54 background-position: 0% 50%;
55 }
56 50% {
57 background-position: 100% 50%;
58 }
59 100% {
60 background-position: 0% 50%;
61 }
62 }
63
64 .unique-facebook-text-Poi123 {
65 z-index: 1;
66 white-space: nowrap;
67 display: flex;
68 align-items: center;
69 }
70</style>
71</head>
72<body class="unique-body-Qwe123">
73
74<div class="unique-facebook-badge-Rty456">
75 <div class="unique-facebook-text-Poi123">
76 Over 4 Million Views On Facebook
77 </div>
78</div>
79
80</body>
81</html>

How to install Facebook views on your Shopify theme

This snippet belongs in sections/main-product.liquid, directly under the Add to cart button, where it reinforces the purchase decision. Expect the whole job to take about 5–10 minutes.

  1. 1From your Shopify admin, open Online Store → Themes, click the button on your live theme and choose Duplicate. Always work on a copy so you can roll back instantly.
  2. 2On the duplicated theme, click … → Edit code to open the theme code editor.
  3. 3Open sections/main-product.liquid in the file tree. If your theme uses different file names, search for the template that renders the area where you want the block to show up.
  4. 4Click Copy code on this page, then paste the snippet directly under the Add to cart button, where it reinforces the purchase decision.
  5. 5The snippet ships with its own scoped <style> block, so you do not need to touch base.css or theme.css. If you prefer to keep CSS centralised, move the contents of the style tag into your theme stylesheet and delete the inline block.
  6. 6Click Save, then hit Preview and check the block on desktop, tablet and mobile widths.
  7. 7When you are happy with the result, publish the duplicated theme from Online Store → Themes → Actions → Publish.

How to customise it

Every value below lives inside the snippet, so you can adapt Facebook views to your brand without touching the rest of the theme.

  • Colours — the snippet uses #fff, #4267B2, #3b5998. Replace those values inside the style block with your brand palette, keeping at least a 4.5:1 contrast ratio between text and background so the block stays accessible.
  • Gradient — swap the linear-gradient(...) declaration for a flat background colour if you want a more minimal, theme-native look.
  • Sizing — adjust the font-size values (14px) and the padding so the block carries the same visual weight as the elements around it.
  • Cornersborder-radius: 7px controls the roundness. Set it to 0 for a sharper editorial look, or increase it for a softer, app-like feel.
  • Copy — rewrite the hard-coded text (for example “Facebook Badge”) in your own brand voice, and translate it if you sell in more than one language.

Common mistakes to avoid

These are the issues merchants run into most often when installing a snippet like this one.

  • Editing the live theme directly. Duplicate it first — a single unbalanced Liquid tag can take a storefront down mid-campaign.
  • Pasting the code into the wrong file. Dropped into layout/theme.liquid instead of sections/main-product.liquid, this block will render on every page of the store, including ones where it makes no sense.
  • Renaming the CSS classes in the markup but not in the style block, or vice versa. The class names have to match exactly or the styling silently disappears.
  • Publishing without testing on a real phone. Most Shopify traffic is mobile, and layout problems almost always surface there first.

Performance notes

What this block costs you in load time, and how to keep that cost at zero.

  • The CSS is inline and scoped to this block, so it adds no extra network request. At a few kilobytes it has no measurable effect on your Lighthouse score.
  • The animation runs on CSS keyframes. Animate only transform and opacity where you can — animating width, height or top forces a layout recalculation on every frame.
  • Run PageSpeed Insights before and after you add the block so you have a concrete number rather than a guess.

SEO & accessibility

How to add this block without damaging your on-page structure or your rich results.

  • Nothing in this snippet should replace your page <h1>. Keep product and page headings intact and use <h2> or <h3> for the block's own heading so the document outline stays clean.
  • If the block shows review or rating content, keep it consistent with the structured data your review app already outputs. Duplicating or contradicting rating markup can cost you the rich result entirely.
  • The block does not create a new URL, so there is no canonical or indexing change to make. It improves on-page engagement signals rather than crawlability.
Frequently asked questions

Facebook views — questions merchants ask

Will this snippet work with my theme?

It is built with standard Liquid, HTML and CSS, so it works with Dawn and virtually every Online Store 2.0 theme, as well as most vintage themes. The only thing that changes between themes is the file you paste it into — if yours has no sections/main-product.liquid, look for the equivalent template that renders the same area.

Do I need an app to use it?

No. This is theme code you own outright: no monthly fee, no third-party script tag, and no app that can break your storefront the next time it updates.

How long does it take to add “Facebook views” to a store?

Most merchants have it live in under fifteen minutes — duplicate the theme, paste the code, adjust the colours and copy, preview on mobile, publish.

The styling looks broken after pasting. How do I fix it?

Confirm you copied the whole snippet including the closing style tag, then check whether one of your theme's own CSS rules is overriding it. If a theme rule wins, increase the specificity of the snippet's selector rather than scattering !important through the file.

Will it slow my store down?

Not meaningfully. It is inline markup with scoped CSS and at most a few lines of vanilla JavaScript — no external libraries, no extra HTTP request. Optimising your product images will always have a far bigger impact on load time.

Can I use it on a client store or a commercial project?

Yes. Every snippet in the MCO Hub library is free to copy, modify and ship on any store, including client work. Attribution is appreciated but not required.

Related snippets

Keep exploring