@misiki/gocommerce-connector 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +11 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +11 -0
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.js +11 -0
- package/dist/services/index.js.map +1 -1
- package/package.json +1 -1
package/dist/services/index.cjs
CHANGED
|
@@ -3168,6 +3168,7 @@ var StoreService = class extends BaseService {
|
|
|
3168
3168
|
// one storefront serves every store, and one store's pixel must never
|
|
3169
3169
|
// load on another's pages.
|
|
3170
3170
|
...adTags(plugins),
|
|
3171
|
+
googleTagManager: googleTags(plugins),
|
|
3171
3172
|
// Discount codes are core: every GoCommerce store takes them, so
|
|
3172
3173
|
// the code box is shown whatever the static record says.
|
|
3173
3174
|
isDiscountCoupons: { ...basePlugins.isDiscountCoupons, active: true },
|
|
@@ -3209,6 +3210,16 @@ function adTags(plugins) {
|
|
|
3209
3210
|
})
|
|
3210
3211
|
);
|
|
3211
3212
|
}
|
|
3213
|
+
function googleTags(plugins) {
|
|
3214
|
+
const s = plugins.get("google-analytics")?.settings ?? {};
|
|
3215
|
+
const id2 = (field) => String(s[field] ?? "").trim();
|
|
3216
|
+
const [account, part] = id2("conversion_label").split("/");
|
|
3217
|
+
const label = part === void 0 ? account : part;
|
|
3218
|
+
const ads = id2("google_ads_id") || (part === void 0 ? "" : account);
|
|
3219
|
+
const tags = [id2("ga4_measurement_id"), ads, id2("gtm_container_id")].filter(Boolean);
|
|
3220
|
+
if (!tags.length) return { active: false };
|
|
3221
|
+
return { active: true, tags, conversions: ads && label ? [{ event: "purchase", label }] : [] };
|
|
3222
|
+
}
|
|
3212
3223
|
function deliverable(base, ships) {
|
|
3213
3224
|
if (ships.everywhere || !ships.countries.length) return {};
|
|
3214
3225
|
const known = new Map((base.countries ?? []).map((c) => [String(c.code).toUpperCase(), c]));
|