Jump to content

Remove UTM tags from URL (regex)


DeanWhitehouse

Recommended Posts

Hello all,

 

I'm trying to generate a regex that will remove UTM parameters from my refferrer URLs.

 

<?php
//"test" parameter is lost
echo preg_replace("/&?utm_(.*)\=[^&]+/","","?utm_source=bottom&utm_medium=widget&test&test&utm_campaign=testcamp");
?>

 

The regex works on removing the paremeters whilst keeping parameters before and after in tact. However parameters in-between are lost.

 

Any ideas would be great.

 

I'm testing the above code on http://writecodeonline.com/php/

Link to comment
https://forums.phpfreaks.com/topic/257622-remove-utm-tags-from-url-regex/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.