We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

gtag js code causing lcp issues

gtag js code causing lcp issues

meenak149
New Member
8 0 0

 

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

Replies 3 (3)

Saurav_Mahtha
Shopify Partner
5 0 0

@meenak149 can you share store url?

Please don't forget to Like & Mark Solution to the post that helped you. Thanks!

Saurav Mahtha | Shopify Wizard 
Crafting E-Commerce Success, One Store at a Time
meenak149
New Member
8 0 0
bestcoursesindigitalworld.com

Website_Speedy
Shopify Partner
151 0 7

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

 

shopify_30_ss.PNG

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 -

<img src="{{ 'image.jpg' | asset_url }}" alt="Product Image" loading="lazy" />

 

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 <head> section of your HTML. This reduces the time the browser spends fetching external stylesheets.

Example - 

<style>

  body {

    margin: 0;

    font-family: Arial, sans-serif;

  }

</style>

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 - 

<script src="{{ 'your-script.js' | asset_url }}" defer></script>

 

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