gtag js code causing lcp issues

Topic summary

A user reports persistent Google Tag (gtag) code causing Largest Contentful Paint (LCP) issues despite removing it from theme.liquid and disconnecting GA4 from Shopify after switching from Dawn to Craft theme. They’re seeking help locating hidden gtag code in Shopify files.

Diagnosis provided:

  • PageSpeed Insights analysis reveals multiple Core Web Vitals issues
  • LCP, FCP (First Contentful Paint), and Speed Index are problematic
  • Home banner image identified as primary LCP culprit
  • Render-blocking JavaScript and CSS affecting FCP

Recommended solutions:

  • Compress the home banner image (already using WebP and preloading)
  • Implement lazy loading for below-the-fold images only
  • Inline critical CSS in the <head> section
  • Defer non-critical JavaScript using the defer attribute
  • Remove problematic third-party JavaScript if issues persist

Status: The discussion remains open with no resolution yet on locating the hidden gtag code, though performance optimization guidance has been provided.

Summarized with AI on October 27. AI used: claude-sonnet-4-5-20250929.

Hi,

A few months back, i created google tag which i didnt make much use of it. Later, i shifted from dawn to craft. The gtag code is not present in the theme. liquid. I have disconnected GA4 from shopify, despite this there is third party blocking time issue with gtag. I am not sure , where else can the code can be present other than theme liquid. please help me where to find the gtag hidden code from the shopify files and delete the code.

Thanks

@meenak149 can you share store url?

Hii @meenak149 , I have examined your website using Google Page Insights, and below is the result for your core web vitals.

As you can see, your TBT is fine, but your other Core Web Vitals, like LCP, FCP, and speed index are concerning.

Images Load Delay

As per the analysis, your home banner image is causing LCP to go high.

Suggested Improvement

Image Compression

You already used WebP format and preloading for the home banner image. I would recommend compressing the image by using an online tool available in the market. This will make the image load faster.

Lazy Loading Other Elements

While your LCP image should load immediately, you can implement lazy loading for images that appear further down the page, but remember to apply this only for the images you do not need immediately at the start. This reduces the initial page load time by loading non-critical images only when the user scrolls near them.

Example -

Product Image

Render Blocking Resources

Your Javascript and CSS are blocking the FCP of your website.

Suggested Improvement

First, for CSS that is essential for rendering the page (above-the-fold content), you can inline it directly in the section of your HTML. This reduces the time the browser spends fetching external stylesheets.

Example -

body { margin: 0; font-family: Arial, sans-serif; }

Additionally, try to defer Non-Critical JavaScript; this will help to allow the page to display the content first and load the scripts later.

Example -

If JavaScript is still causing the issues, i would recommend removing the js line of code from third-party resources.