How to remove leftover Beeketing app code from my website?

Our site used to have an app called Beeketing, then, apparently, it was improperly uninstalled, and the following code still gets injected in content_for_header:

(function (doc, scriptPath) {
    var sc, node, today=new Date(),dd=today.getDate(),mm=today.getMonth()+1,yyyy=today.getFullYear();if(dd<10)dd='0'+dd;if(mm<10)mm='0'+mm;today=yyyy+mm+dd;
    // Load base script tag
    sc = doc.createElement("script");
    sc.type = "text/javascript";
    sc.async = !0;
    sc.src=scriptPath + '?' + today;
    node = doc.getElementsByTagName("script")[0];
    node.parentNode.insertBefore(sc, node);
})(document, 'https://sdk.beeketing.com/js/beeketing.js');
};

How do I get rid of it? Support directed me to ask here.

Hi, Jacob!

I want to help find a way to solve your problem. Can you tell me if the sdk beeketing script is in the script_tags list, which can be seen at this URL ${YOUR_STORE}.myshopify.com/admin/api/2020-01/script_tags.json?

Thanks for reaching out. The script is not present in the list.

So are you sure that this script is in the content_for_header? Could i take a look inside your theme code? You can write me a personal message for further discussion of the problem.

That script is not inside the content_for_header object. I think you can find it in the bk-tracking.liquid snippet.

We don’t have “bk-tracking” snippet, or any other snippet, containing this code.
Here’s part of our theme.liquid:


     {{ content_for_header }}
  

and that’s how resulting html code looks like:


...
(function (doc, scriptPath) {
    var sc, node, today=new Date(),dd=today.getDate(),mm=today.getMonth()+1,yyyy=today.getFullYear();if(dd<10)dd='0'+dd;if(mm<10)mm='0'+mm;today=yyyy+mm+dd;
    // Load base script tag
    sc = doc.createElement("script");
    sc.type = "text/javascript";
    sc.async = !0;
    sc.src=scriptPath + '?' + today;
    node = doc.getElementsByTagName("script")[0];
    node.parentNode.insertBefore(sc, node);
})(document, 'https://sdk.beeketing.com/js/beeketing.js');
};
...
  

In this case, I have a hack solution for you using a replace/remove filters for a content_for_header object to remove an unnecessary script.
https://shopify.dev/docs/themes/liquid/reference/filters/string-filters#remove
https://shopify.dev/docs/themes/liquid/reference/filters/string-filters#replace

You can find use cases in this discussion → https://community.shopify.com/c/Shopify-Discussion/Benefits-of-content-for-header/m-p/686606/highlight/true#M161774

But be careful if you use this method.

Thanks, I’m aware of this method. Was hoping to find a more civilized approach :slightly_smiling_face: Looks like I’ll have to use this manipulation since support isn’t helpful.