Using plugins to swap phone numbers for tracking

We have a marketing campaign that sends out a mailer to potential customers, that mailer has a QR code that has specific parameters on it.

The gist of the flow is “If param X is present, assign cookie. If Cookie is present, change phone number from xxx-xxx-xxxx to yyy-yyy-yyyy” and some other stuff.

Is there a plugin event for this? I’d prefer to do it without messing with more clientside javascript than I have too.

I’m a bit confused. Can you maybe elaborate in more detail what exactly you are trying to do?


The user should already have a session cookie. The easiest option is probably to add a new value to $_SESSION.

An event for what exactly?

So do you want to change the phone number on the server (with PHP) or on the client (with JS)?

So the qr code would have a link like site.com?utm_code=soemthing and i’d like to use that utm_code param to determine if the changes should happen. I don’t know if $_SESSION would work because I need the value to be present for 30 days.

An event for what exactly?

I was thinking something between receiving the request with the ?utm_id in the url and showing the page to the browser. Then I could change the phone number before the browser receives the file.

PHP or JS?

I’d prefer PHP

CC: @halftrainedharry sorry I didn’t reply to your message so pinging you this way :slight_smile:

As you will access $_GET or $_COOKIE to determine if someone used the QR-Code, you could theoretically use any event (that is invoked on a normal MODX page request).

The event OnWebPagePrerender would give you access to the whole parsed output, so you could use string replacement to change the number.

It might be easier though to just use a snippet call in the place where the phone number is output.

Okay, sick, I wasn’t sure if that ran on manager save or if it was where I wanted it to run

Mid-reply edit: I was thinking of docformsave

I’ll go ahead and try to implement it there before closing this just to be sure :slight_smile:

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.