@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.js CHANGED
@@ -3182,6 +3182,7 @@ var StoreService = class extends BaseService {
3182
3182
  // one storefront serves every store, and one store's pixel must never
3183
3183
  // load on another's pages.
3184
3184
  ...adTags(plugins),
3185
+ googleTagManager: googleTags(plugins),
3185
3186
  // Discount codes are core: every GoCommerce store takes them, so
3186
3187
  // the code box is shown whatever the static record says.
3187
3188
  isDiscountCoupons: { ...basePlugins.isDiscountCoupons, active: true },
@@ -3223,6 +3224,16 @@ function adTags(plugins) {
3223
3224
  })
3224
3225
  );
3225
3226
  }
3227
+ function googleTags(plugins) {
3228
+ const s = plugins.get("google-analytics")?.settings ?? {};
3229
+ const id2 = (field) => String(s[field] ?? "").trim();
3230
+ const [account, part] = id2("conversion_label").split("/");
3231
+ const label = part === void 0 ? account : part;
3232
+ const ads = id2("google_ads_id") || (part === void 0 ? "" : account);
3233
+ const tags = [id2("ga4_measurement_id"), ads, id2("gtm_container_id")].filter(Boolean);
3234
+ if (!tags.length) return { active: false };
3235
+ return { active: true, tags, conversions: ads && label ? [{ event: "purchase", label }] : [] };
3236
+ }
3226
3237
  function deliverable(base, ships) {
3227
3238
  if (ships.everywhere || !ships.countries.length) return {};
3228
3239
  const known = new Map((base.countries ?? []).map((c) => [String(c.code).toUpperCase(), c]));