Impossible to replace or remove texte in {{content_for_header}}

Hi,

I tried to replace the text in {{content_for_header}} in theme.liquid file, but it wouldn’t work.
Here are my codes :

{% comment %}
{{ content_for_header }}
{% endcomment %}
{{ content_for_header | replace: ‘Google Gtag Pixel’, ‘Need delete Google Gtag Pixel’}}

OR

{% capture h_content %}
{{ content_for_header }}
{% endcapture %}

{% if template contains ‘Google Gtag Pixel’%}
{{ h_content | remove: “Need delete Google Gtag Pixel” }}

{% else %}
{{ content_for_header }}

{% endif %}

Thanks for your help

Hi @shopiAll ,

This is not possible, you cannot edit it. Refer https://shopify.dev/themes/architecture/layouts#content_for_header

Hope it is clear to you.

I’m Richard Nguyen - CRO Expert at PageFly- Free Landing Page Builder.

Regards your concern.

You can’t use replace or remove the filter on content_for_header

It’s not recommended to modify the content_for_header but, I will show you how to modify it.

First, comment it

{%- comment -%}

{{ content_for_header }}

{%- endcomment -%}

This will let you update the file with theme watch

Second, Use capture for custom content_for_header

{% capture custom_content_for_header %}

{{ content_for_header | replace: ‘your-text-to-be-replaced’, ‘new-text’

{% endcapture %}

Last, print your custom content for header

{{ custom_content_for_header }}

If you feel my answer is helpful, like it or mark it as a solution. Let me know if you have any questions.

Best regards,

Richard | PageFly

Hi RichardNguyen,

Thanks for your reply, I tried your method, but it wouldn’t work with this code :

{%- comment -%}

{{ content_for_header }}

{%- endcomment -%}

{% capture custom_content_for_header %}

{{ content_for_header | replace: ‘Google Gtag Pixel’, ‘Need delete Google Gtag Pixel’ }}

{% endcapture %}

{{ custom_content_for_header }}

My goal is to remove Google Gtag Pixel or replace ‘MyAdsIDxxxx’ by an other string (or ID), but shopify woundn’t do it, i don’t know how other user fixe this problem, i guess I’m not the only one who had this problem.

here is the code i would change something in it :
“Google Gtag Pixel”:{“conversionId”:“AW-0”,“eventLabels”:[{“type”:“page_view”,“action_label”:“AW-10xxxxxx/AdsIDxxxx-XwNso”}

Best regards

Hi @shopiAll ,

Please send your site and if your site is password protected, please send me the password. I will check it.

Hi @LitExtension

Thanks for your reply and help, i will send to you the collaborator request code so that you could access our backoffice.

Thanks for you help

Hi @shopiAll ,

Please change code:

{{ content_for_header }}

=>

{%- comment -%}
    {{ content_for_header }}
    {%- endcomment -%}
    {% capture custom_content_for_header %}
    {{ content_for_header | replace: 'Google Gtag Pixel', 'Null Google Gtag Pixel' }}
    {% endcapture %}
    {{ custom_content_for_header }}

Hope it helps!

Hi @shopiAll ,

I checked and the code is not in ‘content_for_header’, it is added by alireviews_core.liquid file, you can find it here.

Hope it helps!

Hi @shopiAll ,

Sorry, I tried everything but had no success, it may be managed by Shopify, you cannot edit it.

So I recommend you to contact Shopify directly, they will help you to remove it.

Refer https://help.shopify.com/en/questions#/contact

Hope it helps!

Hi LitExtension,
Thanks for all your help,
I contacted Shopify, and I’ve tried everything with Shopify support, apparently this is a bug that Shopify may fix, so my issue is still not through tech support. They offered to install applications sold on their marketplace.
Anyway, I’m like even disappointed that they are not able to solve this problem and I have to pay an additional module for that.
Best regards

Hi @shopiAll ,

Sympathize with you. It might be the only solution.

If it helped you solve your issue, please mark it as a solution. Thank you and good luck.