This will replace your original string with number:
var original = "Getting Closer! Only $:is_left_to_reach_cart_total_goal away from FREE SHIPPING!";
var number = 1;
var newone = original.replace(/:is_left_to_reach_cart_total_goal/g, number);
you can also create an array of placeholders and values you want to replace and then reduce it like this:
var original = "Getting Closer!"
+ "Only $:is_left_to_reach_cart_total_goal away from FREE SHIPPING!"
+ "Additional info: $:link";
var toReplace = [
{ key: ":is_left_to_reach_cart_total_goal", value: "1" },
{ key: ":cart_total_currently", value: "2" },
{ key: ":cart_total_goal", value: "3" },
{ key: ":cart_products_quantity_currently", value: "4" },
{ key: ":cart_products_quantity_goal", value: "5" },
{ key: ":is_left_to_reach_products_quantity_goal", value: "6" },
{ key: ":link", value: "7" },
{ key: ":button", value: "whateverelse" }
];
var result = toReplace.reduce(function(r, item) {
return r.replace(new RegExp(item.key, "g"), item.value);
}, original);
console.log(result);
NOTICE: using g flag to replace all occurences of string.
replace.