Popup on site not working on QR code scan

i generated QR code in shopify marketing tab. created popup in app optimonk in shopify… popup triger condition set to js event call and page url if contains= utm_campaign=a5f1a7. But popup not working properly it appears sometimes when i use QR link directly…and not working completely when i scan QR code.
@tim_tairli i ask you for help because your solution works for me

There are a lot of things which can go wrong – need more details.

@sajeelbaig ,

This is a very common QR + popup tracking issue, and the behavior you’re seeing is expected with the current setup.

  1. Shopify QR codes redirect before landing on the final page
    → UTM params can be lost or delayed
  2. OptiMonk loads before the URL params are fully available
  3. On mobile (QR scan), Safari/Chrome privacy handling makes this worse
  4. That’s why:
  • Sometimes works when pasting the link
  • Mostly fails when scanning the QR

Step 1: Stop relying only on page URL contains

Instead, convert the UTM into a JS event or cookie.

Add this in Theme → Edit code → theme.liquid (before </body>):

<script>
(function () {
  const params = new URLSearchParams(window.location.search);
  if (params.get('utm_campaign') === 'a5f1a7') {
    window.optimonk = window.optimonk || [];
    window.optimonk.push(['event', 'qr_campaign']);
  }
})();
</script>

Step 2: Update OptiMonk trigger

  • Trigger type → Custom JavaScript Event
  • Event name → qr_campaign

Remove URL condition
Use only JS event