Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
829 views
in Technique[技术] by (71.8m points)

google analytics - utm_source and utm_medium gets lost in SPA

I've got a weird problem with my SPA application and analytics. The source/medium parameters are being lost during the session for some users.

I'm using the history API using Google Tag Manager as recommended, and it works. But for approximate 30% of the users loose their utm parameters and becomes referrals. I don't understand this behaviour, anyone seen this before?

So, I know that 100% are

(source/medium) = mySource / affiliate

but looking in analytics, approximately 30% are loosing their utm parameters and it becomes:

(source/medium) = mySource / affiliate (70%)
(source/medium) = mysource.com / referral (30%)

Any suggestions? I'm a bit lost right now.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As the sites is a Single Page Application (SPA), you are most likely facing the problem of 'Rogue Referral'.

If this is the case, what happens, is that you overwrite the location field in the Analytics hit, losing the original UTM parameters, whereas referral is still sent with the hit, so Analytics recognizes the second hit as a new traffic source. One of the solutions is to store the original page URL and send it as the location, while sending the actual visited URL in the page field.

A very good article on this topic with further tips, by Simo Ahava, is available for your help.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...