@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.js
CHANGED
|
@@ -3166,6 +3166,7 @@ var StoreService = class extends BaseService {
|
|
|
3166
3166
|
// one storefront serves every store, and one store's pixel must never
|
|
3167
3167
|
// load on another's pages.
|
|
3168
3168
|
...adTags(plugins),
|
|
3169
|
+
googleTagManager: googleTags(plugins),
|
|
3169
3170
|
// Discount codes are core: every GoCommerce store takes them, so
|
|
3170
3171
|
// the code box is shown whatever the static record says.
|
|
3171
3172
|
isDiscountCoupons: { ...basePlugins.isDiscountCoupons, active: true },
|
|
@@ -3207,6 +3208,16 @@ function adTags(plugins) {
|
|
|
3207
3208
|
})
|
|
3208
3209
|
);
|
|
3209
3210
|
}
|
|
3211
|
+
function googleTags(plugins) {
|
|
3212
|
+
const s = plugins.get("google-analytics")?.settings ?? {};
|
|
3213
|
+
const id2 = (field) => String(s[field] ?? "").trim();
|
|
3214
|
+
const [account, part] = id2("conversion_label").split("/");
|
|
3215
|
+
const label = part === void 0 ? account : part;
|
|
3216
|
+
const ads = id2("google_ads_id") || (part === void 0 ? "" : account);
|
|
3217
|
+
const tags = [id2("ga4_measurement_id"), ads, id2("gtm_container_id")].filter(Boolean);
|
|
3218
|
+
if (!tags.length) return { active: false };
|
|
3219
|
+
return { active: true, tags, conversions: ads && label ? [{ event: "purchase", label }] : [] };
|
|
3220
|
+
}
|
|
3210
3221
|
function deliverable(base, ships) {
|
|
3211
3222
|
if (ships.everywhere || !ships.countries.length) return {};
|
|
3212
3223
|
const known = new Map((base.countries ?? []).map((c) => [String(c.code).toUpperCase(), c]));
|