Solved

Google Analytics User Defined / Custom Variable not working

Posted on 2011-03-11
3
705 Views
Last Modified: 2013-12-07
Hi Experts,

I have installed this tracking code. I would like to track if the page being viewed by the user is private or a public page.

This is my code below.

If the page is public, public is assigned where the word 'public' is currently being shown, if it is private, then private is assigned instead.

When I log into my analytic account the user defined variable only has 'not set' - I cannot see wither public or private there?

I have set this up over 24 hours ago so don't think it's a delay problem.

Is there something wrong with this code?

It is placed as the last part of the head before </head>

Thanks
<script type="text/javascript">

		  var _gaq = _gaq || [];
		  _gaq.push(['_setAccount', 'UA-MY-CODE-IVE-CHANGED']);
		  _gaq.push(['_trackPageview']);
		  _gaq.push(['_setCustomVar', 1,'Page Type', 'public', 3]);
		  
		  		  (function() {
		    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
		  })();
		
		</script>

Open in new window

0
Comment
Question by:bigMlittleC
  • 2
3 Comments
 
LVL 31

Accepted Solution

by:
gwkg earned 500 total points
ID: 35144183
Try setting the custom var before trackPageview
0
 

Author Comment

by:bigMlittleC
ID: 35146019
Thanks, I will give that a try. It can take a while for the results to show (24hours+). Bare with me. If it works I shall be awarding you the points!
0
 

Author Closing Comment

by:bigMlittleC
ID: 35164272
Sorry for the delay.

Many thanks. It is now picking up the variables.

All the best
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now