Skip to content

Instantly share code, notes, and snippets.

@latestscoop
Last active June 22, 2018 12:23
Show Gist options
  • Save latestscoop/7eb4e5c216230bebe209e9aaa16c4894 to your computer and use it in GitHub Desktop.
Save latestscoop/7eb4e5c216230bebe209e9aaa16c4894 to your computer and use it in GitHub Desktop.
Google Analytics: Goals - Regular Expressions
All the following regex will pick up the goal trigger from a URL parameter on any page.
Example URL's with paramters: https://www.example.com/?id=value, http://www.example.com/cat/subcat/?id=value
This regex will pick up any of the following values; value,Value,ANYTHINGvalueANYTHING
Example URL's; http://www.example.com/?id=Value, http://www.example.com/?id=TEXTvalueTEXT,
.*(\?id=).*([v|V]alue).*
This regex will pick up the following values; value one, Value One, valueone, ValueOne, ANYTHINGvalueoneANYTHING
Example URL's; http://www.example.com/?id=Value One, http://www.example.com/cat/subcat/?id=TEXTvalue oneTEXT,
.*(\?id=).*([v|V]alue\s*[o|O]ne).*
This regex will pick up the following values; valueB, ValueB
Example URL's; http://www.example.com/?idA=valueA&idB=valueB&id=valueC
.*(idB=[v|V]alueB).*
About regex on Analytics: https://support.google.com/analytics/answer/1034324?hl=en
Test your regex: https://www.regextester.com/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment