1

I am generating QR Codes and to keep it as clear as possible, I want a short URL, then expand to a full address + UTM or at least have Google Analytics understand.

QR Code payload:

https://example.com/as?q=A01

The website is on WP, so I can redirect to:

https://example.com/A-Subject?q=A01

What I am looking for is the next step: Having Google analytics understanding that:

  • Source: Business card
  • Medium: QR Code
  • Campaign: 01

I have tried filters in GA => search and replace /?q=A01 with ?utm_source=cards&utm_medium=QRCode&utm_campaign=A01

Problem is that even if the active page is displayed with the correct URL, the UTM parameters are not used/understood by GA (source = (none) for example)

Any idea of what to do?

  • Plugin in WP to rewrite URL?
  • Javascript in WP to rewrite URL?
  • GA ?

[edit] Doing a bit more research, I suspect the easiest would be to go through .htaccess and do some url rewritting on add_action

In my case, depending on the first letter of the parameter, I would have a few possible outputs: A = QR Code on a card => q=A01 would be rewritten into

utm_source=cards&utm_medium=QRCode&utm_campaign=A01

B = QR Code on a poster => q=B07 would be rewritten into

utm_source=poster&utm_medium=QRCode&utm_campaign=B07

1
  • Ok, so it looks like the only complexity is in building the regex, and I'm afraid I'm not great there. Any advice? Code is letter + 2 digits, Letter A means cards and letter B or C means poster /?q=A01 becomes ?utm_source=cards&utm_medium=QRCode&utm_campaign=A01 and /?q=B07 becomes ?utm_source=poster&utm_medium=QRCode&utm_campaign=B07
    – Nepomucene
    Jun 8 at 16:05

1 Answer 1

1

The solution I used was within the WP Engine, and using conditional redirects by matching args.

my QR Codes were: https://example.com/shrt?q=A01 And I used 301 redirects

Source: /shrt?$

Dest: /long-name/?utm_source=cards&utm_medium=QRCode&utm_campaign=A01

Match Args: q=A01

Pretty sure there would be fancier solutions, but as I create my QRCodes/campaigns one by one, it only takes me 30s to add a new redirect rule when I create a new QRCode...

Problem solved!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.