Google Analytics and Comment Tracking - HL Vanilla Community
<main> <article class="userContent"> <p>When someone is looking at Vanilla Comments, the URL is appended with <strong>#vanilla-comments</strong>.</p><p>Out of the box, Google Analytics will ignore the hashtag, so you will not be able to see the differentiator between your content and comment views. To separate them, you have to modify your Google Analytics code to:</p><pre class="code codeBlock" spellcheck="false" tabindex="0">gtag('config', 'GA_TRACKING_ID', { 'page_path': location.pathname + location.hash }); </pre><h2 data-id="notable-caveats">Notable caveats</h2><p>This will <strong>not work</strong> without refreshing the page. So it works best when people click to read/view comments. You need <a href="https://www.simoahava.com/gtm-tips/track-url-fragments-as-pageviews/" rel="nofollow noreferrer ugc">Google Tag Manager</a> to track this behaviour in a non-refresh state.</p><p>Also, this change means that all URLs on your website that have a <strong>#</strong> will be tracked as separate URL records in your Google Analytics, so make sure this is on a filtered view.</p> </article> </main>