Hello, I am currently facing some challenges in setting up my experiment for analytics. The issue lies in the fact that I do not have different URLs, but rather different JSP pages for display purposes. For example, I have the following scenario: www.mysite.com/search (which points to search1.jsp) and www.mysite.com/search (which points to search2.jsp)
PS: www.mysite.com/search is just an example.
Both pages can be accessed using the same URL (www.mysite.com/search), and I determine how each page is displayed from the controller.
To configure my experiment, I followed these steps: (linking to an image since images cannot be posted here)
Additionally, I included the following JavaScript code in my JSP variation page 1:
<script src="//www.google-analytics.com/cx/api.js?experiment=xXxxXXXxxXXxxXXXxX"></script>
<script>
cxApi.setChosenVariation(1);
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);
_gaq.push(['_trackPageview']);
(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>
I have a couple of questions regarding this setup as I am not seeing any results from Google Analytics:
1 - Is the configuration correct? Will Google recognize that the user is inside Experiment 1 when accessing this page?
2 - Do I need to use the code provided by Google when creating my experiment? Or is the JavaScript code sufficient? If the Google code is required, should it be added to all pages?
Thank you in advance.