Browse Source

NEW Ajout de 2 dimensions personnalisées à Google analytics : mission du visiteur et nom du collège

julien.legrand 8 years ago
parent
commit
8b2942fbd2

+ 5 - 0
CG67.FicheCollege.sln

@@ -26,6 +26,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BDD", "BDD", "{1A8B53A5-4E3
 		BDD\2016-12-15 Modification libellé gestionnaire par interim.sql = BDD\2016-12-15 Modification libellé gestionnaire par interim.sql
 		BDD\2016-12-15 Modification libellé gestionnaire par interim.sql = BDD\2016-12-15 Modification libellé gestionnaire par interim.sql
 	EndProjectSection
 	EndProjectSection
 EndProject
 EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C2424716-4431-4694-8127-7535399468FA}"
+	ProjectSection(SolutionItems) = preProject
+		Notes\Google Analytics.txt = Notes\Google Analytics.txt
+	EndProjectSection
+EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
 		Debug|Any CPU = Debug|Any CPU

+ 14 - 0
Notes/Google Analytics.txt

@@ -0,0 +1,14 @@
+Les statistiques d'accès avec Google Analytics nécessitent la création d'une dimension personnalisée.
+Voici la marché à suivre : https://support.google.com/analytics/answer/2709829?hl=en&topic=2709827&ctx=topic
+
+Nom de la dimension personnalisée : CD67_Visiteur
+Portée : Utilisateur
+
+Test Nok :
+ga('create', 'UA-6108365-40', 'auto');
+ga('set', 'dimension1', '<%=user%>');
+ga('send', 'pageview');
+
+Site :
+var dimensionValue = 'SOME_DIMENSION_VALUE';
+ga('set', 'dimension2', dimensionValue);

+ 2 - 1
Web/CG67.FicheCollege.Web/FicheCollege.aspx

@@ -19,7 +19,8 @@
 
 
       ga('create', 'UA-6108365-40', 'auto');
       ga('create', 'UA-6108365-40', 'auto');
       ga('send', 'pageview', {
       ga('send', 'pageview', {
-          'Visitor': '<%=user%>'
+          'dimension1': '<%=user%>',
+          'dimension2': '<%=nomCollege%>'
       });
       });
     </script>
     </script>
 
 

+ 9 - 3
Web/CG67.FicheCollege.Web/FicheCollege.aspx.cs

@@ -24,7 +24,8 @@ namespace CG67.FicheCollege
     public partial class FicheCollege : System.Web.UI.Page
     public partial class FicheCollege : System.Web.UI.Page
     {
     {
         public string user;
         public string user;
-       
+        public string nomCollege;
+
         protected void Page_Load(object sender, EventArgs e)
         protected void Page_Load(object sender, EventArgs e)
         {
         {
             //Intialisation des paramètres
             //Intialisation des paramètres
@@ -34,7 +35,8 @@ namespace CG67.FicheCollege
             HttpContext.Current.Session["AnneeMoins1"] = annee - 1;
             HttpContext.Current.Session["AnneeMoins1"] = annee - 1;
             HttpContext.Current.Session["RNE"] = Request["RNE"];           
             HttpContext.Current.Session["RNE"] = Request["RNE"];           
             string domain = "DC=cg67,DC=fr";
             string domain = "DC=cg67,DC=fr";
-           
+            
+            //Détermination de la mission ou du statut utilisateur pour les statistiques
             using (var rootEntry = new DirectoryEntry("LDAP://CG67/" + domain, null, null, AuthenticationTypes.Secure))
             using (var rootEntry = new DirectoryEntry("LDAP://CG67/" + domain, null, null, AuthenticationTypes.Secure))
             {
             {
                 using (var directorySearcher = new DirectorySearcher(rootEntry, String.Format("(sAMAccountName={0})", HttpContext.Current.User.Identity.Name.Replace("CG67\\",""))))
                 using (var directorySearcher = new DirectorySearcher(rootEntry, String.Format("(sAMAccountName={0})", HttpContext.Current.User.Identity.Name.Replace("CG67\\",""))))
@@ -74,7 +76,11 @@ namespace CG67.FicheCollege
                 //modif car si code rne null provoque une erreur
                 //modif car si code rne null provoque une erreur
                 XmlNode xmlFicheCollege = ServiceFiche.GetFicheCollege(Session["RNE"].ToString(), int.Parse(Session["annee"].ToString()));
                 XmlNode xmlFicheCollege = ServiceFiche.GetFicheCollege(Session["RNE"].ToString(), int.Parse(Session["annee"].ToString()));
 
 
-                this.Title = xmlFicheCollege.SelectSingleNode("college/Etablissement/NomCollegePourPresentation").InnerText;
+                //Enregistrement du nom du collège pour les statistiques
+                nomCollege = xmlFicheCollege.SelectSingleNode("college/Etablissement/NomCollegePourPresentation").InnerText;
+
+                //Affichage des données
+                this.Title = nomCollege;
                 xmlFicheCollege.SelectSingleNode("college").InnerXml += entete.DocumentElement.OuterXml;
                 xmlFicheCollege.SelectSingleNode("college").InnerXml += entete.DocumentElement.OuterXml;
                 this.Xml1.DocumentContent = xmlFicheCollege.OuterXml;
                 this.Xml1.DocumentContent = xmlFicheCollege.OuterXml;
                 this.DataBind();
                 this.DataBind();