title: Replace Google Analytics pageview URLs with Google Tag Manager
body: <p>I have migrated from GA to GTM and I need know how to replace paths when sending pageviews URLs to GA. The reason is that our website has not category slugs, as example:</p>
  
  <p>www.mysite.com/category-name/</p>
  
  <p>While we want to track:</p>
  
  <p>www.mysite.com/category/category-name/</p>
  
  <p>IN GA we used to push a category slug replacing pageview URL:</p>
  
  <p>ga('send', 'pageview', '');</p>
  
  <p>This helped us to group together all categories. I think that we can achieve the same tracking in GTM using a Virtualpageview datalayer:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  dataLayer.push({
    'event':'VirtualPageview',
    'virtualPageURL':'&lt;?php echo str_replace(get_bloginfo('url'),"/category/",get_permalink()); ?&gt;', 'virtualPageTitle':'&lt;?php echo the_title(); ?&gt;'
    });
  'virtualPageTitle':'&lt;?php echo the_title(); ?&gt;'
  &lt;/script&gt;
  </code></pre>
  
  <p>So I created a GTM "Pageviews" tag with the following "Field to set":</p>
  
  <pre><code>page &gt; {{virtualPageURL}}
  title &gt; {{virtualPageTitle}} 
  </code></pre>
  
  <p>This tag is triggered with a custom event "VirtualPageview". I also created 2 dataLayer variables: virtualPageTitle and virtualPageURL. However GA continue tracking categories without slugs.</p>
  
  <p>I will appreciate if somebody could tell me what's wrong in my settings, or how can I replace our categories URLs in order to send category slugs to GA.</p>
  
  <p>Thank you.</p>