Analytics
2.3K members online now
2.3K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

How to avoid duplicate pageviews?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello,

 

According to Google Tag Manager, I get duplicate pageview hits for each page. This does probably have to do with the fact that I am using custom dimensions.

 

I am using an online platform that allows me to connect to Google Analytics by checking a tick box and entering the GA tracking ID. The DOM then includes the following code which I do not have access to:
ga('create', 'UA-XXXXXXXX-1', 'auto');
ga('send', 'pageview');

I set up a Custom Dimension in the JS code using the following code:

// Account type
ga('set', 'dimension1', CRM.account.type);
ga('send', 'pageview');

 

If I remove the send function in the JS code, the custom dimension values are not sent to Google Analytics.

 

Would I need to use commands like the one below?
ga ('send', 'pageview', {'dimension1': 'CRM.account.type'}); 


Any suggestions are more than welcome!

Thanks,
Sandra

 
1 Expert replyverified_user

Re: How to avoid duplicate pageviews?

Top Contributor
# 2
Top Contributor
Hi Sandra,

Yes, you need to use the code like this:

ga('create', 'UA-XXXXXXXX-1', 'auto');
ga ('send', 'pageview', {'dimension1': 'CRM.account.type'});

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: How to avoid duplicate pageviews?

[ Edited ]
Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi Arnold,

I can't access the two lines of code that appear in DOM (or put any code in between them).
In JavaScript on the other hand, I just tried using three commands like ga ('send', 'pageview', {'dimension1': 'CRM.account.type'}); for my three custom dimensions but I didn't get the desired results. The tag assistant notifies me of the following "Same web property ID is tracked twice" and I get four hits, one general one and then one for each custom dimension.

Any ideas?


Re: How to avoid duplicate pageviews?

Top Contributor
# 4
Top Contributor
Hi Sandra,

The problem is that you need to send your custom variable with the pageview. So you need to use the set command before the send command or to set your custom variable in your send command. If you cannot make changes to the inserted code maybe a solution would be disabling the code inserted by the online platform and adding the customized tracking code manually to the template.
Let me know if you have more questions.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: How to avoid duplicate pageviews?

Participant ✭ ✭ ☆
# 5
Participant ✭ ✭ ☆
You can set dimension scope to session and use event:

ga('set', 'dimension1', CRM.account.type);
ga("send","event","Category","Action","Label",{nonInteraction: true});

Re: How to avoid duplicate pageviews?

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭
Hi Tomasz,

I changed the JS code to
ga('set', '&uid', Customer.id);
ga('set', 'dimension1', CRM.account.type);
ga('set', 'dimension2', Customer.tags);
ga('send','event','Custom dimensions','browse','CRM data',{nonInteraction: true});

And I no longer get an error when using Google Tag Manager which is good.
However, in Reporting in Google Analytics, I can no longer include the custom dimensions in Behavior > Site Content but can view them in Behavior > Events now.

Did I set it up correctly? If so, is there a way to connect the data so that I have consistent statistics since I implemented the custom dimension?

Thanks,
Sandra

Re: How to avoid duplicate pageviews?

Participant ✭ ✭ ☆
# 7
Participant ✭ ✭ ☆

Did you change dimension scope to session?

 

dimension-scope.png

Re: How to avoid duplicate pageviews?

Visitor ✭ ✭ ✭
# 8
Visitor ✭ ✭ ✭
I had it on Session already. Is that an issue?

Re: How to avoid duplicate pageviews?

Participant ✭ ✭ ☆
# 9
Participant ✭ ✭ ☆
In your case it should be set on Session.
But you have to wait until all data is processed.
You can read more about scopes in this article:
https://support.google.com/analytics/answer/2709828#scope

Re: How to avoid duplicate pageviews?

Visitor ✭ ✭ ✭
# 10
Visitor ✭ ✭ ✭
Would I be able to include the custom dimensions in the Site Content section in Reporting then?

Thanks!