Email From Shopify About Removing Code From Online Store > Preferences

sarkpk
New Member
2 0 0

Hi Everyone!

Just a little help I required, I received an email from Shopify about removing the code from the preferences section. Following is the email which I received from Shopify:

You are receiving this message as your store, has content within the Google Analytics Additional Javascript preference field found in Online Store > Preferences.
This message serves as notification of changes you can expect related to this field going forward. While you can still add custom JavaScript to the field for tracking use cases such as Google Analytics and Google Tag Manager, custom JavaScript for other customizations will no longer be possible.

You can expect this permanent change to go into effect on March 15, 2021. We recommend moving JavaScript from this preference field to your checkout.liquid theme file before this date.

 

Following is the code which is in the preferences section, can someone suggest me where to move in the checkout.liquid? Thanks very much.

 

var crafty_cfg = document.createElement('script');
crafty_cfg.setAttribute('type', 'text/javascript');
var cc_config = {
// CONFIGURATION (REQUIRED)
_cp_access_token : 'cb525-754c2-4d780-02bb3',
// CONFIGURATION (OPTIONAL)
_cp_hide_fields : false, // Hide address fields until result selected
_cp_button_below_postcode : false, // Place the 'Find Address' button below the postcode field rather than next to it - true/false
_cp_button_text : 'Find Address', // Text displayed on the lookup button
_cp_button_class : '', // Class applied to the button
_cp_busy_img_url : '' // The url of the image to show while waiting for lookup results, e.g. a spinning wheel
};
crafty_cfg.innerHTML = 'var cc_config = ' + JSON.stringify(cc_config) + ';';
document.getElementsByTagName("head")[0].appendChild(crafty_cfg);
 
var _cc_s = document.createElement('script');
_cc_s.type= 'text/javascript';
_cc_s.src=_cc_url;
document.getElementsByTagName("head")[0].appendChild(_cc_s);
0 Likes
SagarSukhanandi
Explorer
154 26 42

@sarkpk Could you please add me as staff so i will move code to checkout.liquid file

If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on sagar.sukhanandi@gmail.com regarding any help
0 Likes
sarkpk
New Member
2 0 0

Hi @SagarSukhanandi

Thanks for your reply and that is really helpful.

However, I can move the code myself into the checkout.liquid file. I just want to know that in which area should I move it? 

Because if I move it in head or in body then code starts appearing in checkout.

0 Likes
PaulNewton
Shopify Partner
2573 135 450

T

I'm not 100% clear what your previous code was trying to accomplish, but for you or other merchants needing resources Littledata has started a small guide for merchants needing to replace things.

https://blog.littledata.io/2021/02/22/replacing-additional-google-analytics-javascript-for-shopify-s... 

 

Just in case you may need to at minimum wrap your code in a script tag if your trying to put it into theme files:

<script>



</script>

 

Problem Solved? ✔️Accept and ? Like the solution so you can help others.
Buy me a coffee ☕ paypal.me/paulnewton or donate to eff.org
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
0 Likes
SagarSukhanandi
Explorer
154 26 42

@sarkpk Happy to help you on this issue

Copy below code and put at the end of your checkout.liquid file

<script>
var crafty_cfg = document.createElement('script');
crafty_cfg.setAttribute('type', 'text/javascript');
var cc_config = {
// CONFIGURATION (REQUIRED)
_cp_access_token : 'cb525-754c2-4d780-02bb3',
// CONFIGURATION (OPTIONAL)
_cp_hide_fields : false, // Hide address fields until result selected
_cp_button_below_postcode : false, // Place the 'Find Address' button below the postcode field rather than next to it - true/false
_cp_button_text : 'Find Address', // Text displayed on the lookup button
_cp_button_class : '', // Class applied to the button
_cp_busy_img_url : '' // The url of the image to show while waiting for lookup results, e.g. a spinning wheel
};
crafty_cfg.innerHTML = 'var cc_config = ' + JSON.stringify(cc_config) + ';';
document.getElementsByTagName("head")[0].appendChild(crafty_cfg);
 
var _cc_url = "https://cc-cdn.com/shopify-uk/scripts/v1/shopify_crafty_clicks.js";
var _cc_s = document.createElement('script');
_cc_s.type= 'text/javascript';
_cc_s.src=_cc_url;
document.getElementsByTagName("head")[0].appendChild(_cc_s);
</script>

 

If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on sagar.sukhanandi@gmail.com regarding any help
0 Likes