ElPistolero
ElPistolero

Reputation: 103

Global Site Tag Migration - Sample rate not working for pageviews

I've migrated from Universal to Global Site Tag. I've got sample_rate:50. It's not working for Pageviews. Now: pageviews = 100. Expected: pageviews = 50. Can you please show me an example that works?

https://jsfiddle.net/5owj671h/

<script async src="https://www.googletagmanager.com/gtag/js?id=<?
=$gaTrackingCode?>"></script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date());

gtag('config', '<?= $gaTrackingCode ?>', {
'custom_map': {'dimension3': hasAdBlock},
'sample_rate': 50
});

gtag('event', 'page_view', { 'send_to': '<?= $gaTrackingCode ?>', 
'sample_rate': 50 });
</script>

Upvotes: 3

Views: 492

Answers (2)

zborovskaya
zborovskaya

Reputation: 1143

sampleRate works with users, not page views. And I guess sample_rate is a wrong name.

Upvotes: 0

ElPistolero
ElPistolero

Reputation: 103

The gtag scripts sends the pageviews automatically so when I stopped sending pageviews, it worked.

Upvotes: 1

Related Questions