Replace analytics tracking code wtih regex
I need to do a huge replacement on my site 400+ items with the new asynchronous tracking.
pageTracker._trackEvent('footer_search', 'search', 'search-footer');
Im using aptana开发者_JAVA技巧 and it has a regex replacement, it needs to look like this, notice the [ ].
_gaq.push(['_trackEvent', 'footer_search', 'search', 'search-footer']);
Much appreciated!
Try
search for
pageTracker._trackEvent\('([A-Za-z0-9-_]+)', '([A-Za-z0-9-_]+)', '([A-Za-z0-9-_-]+)'\);
replace with
_gaq.push(['_trackEvent', '$1', '$2', '$3']);
Hopefully you can see where I'm going with this.
pageTracker\.([^\(]+)\(([^\)]+)\)
_gaq.push(['$1', $2]);
精彩评论