Add google analytics to SharePoint, SharePoint 2013 and SharePoint online (Office 365)

Intro

Google ana­lyt­ics can pro­vide a very con­cise overview on how your web­site is doing. It gen­er­ates nice reports and hosts clear reports.

It is also pos­si­ble to use google ana­lyt­ics to track usage on an intranet site built on Share­Point, Share­Point 2013 or Share­Point online.

In this tuto­r­i­al i will explain the steps to imple­ment ana­lyt­ics to your Share­Point site.

 

Prerequisites:

  1. You need a google account
  2. You need per­mis­sions to edit (master)pages in Share­Point

Steps

In short:

  1. go to google.com/analytics to gen­er­ate an ana­lyt­ic­sID
  2. copy some code to the site you’d like to track

Not so short:

  • go to http://google.com/analytics
  • Cre­ate an account (see this as a group for the sites you track)
  • Add a new prop­er­ty (a new site to track)

google analytics

  • Retrieve the track­ing-ID
  • Select the script pro­vid­ed (start at <script> and copy includ­ing </script>)
  • trackingID code
  • Open Share­Point design­er and nav­i­gate to the mas­ter­page fold­er.
  • Open the mas­ter­page you are using for your intranet (in my case its Seat­tle)
  • Open and edit the .html ver­sion (the .aspx will be mod­i­fied by Share­Point after edit­ing)
  • scroll all the way to the bot­tom and look for the tag </body>find body tag
  • past the ana­lyt­ics code just above the </body> tag past analytics code
  • save the mas­ter­page

Now the track­ing data will be sent to google ana­lyt­ics. It may take some time before the results start to roll in but they will.

 

first resultsFirst results com­ing in after just a minute.

 

 

Hide the Recent tab in SharePoint Navigation

I have nev­er liked the “Recent” tab in the Share­Point Quick­Start nav­i­ga­tion.

Hide Recent 1

So here is a way to hide it for­ev­er! We do this by edit­ing the prop­er­ties of the link in the nav­i­ga­tion set­tings of the site. We will dis­play the link to all mem­bers of a new­ly cre­at­ed group. The thing is that there are no mem­bers in that group (oth­er than the farm admin­is­tra­tor of course).

 

Step 1

Go into Site set­tings.

Hide Recent 2

Step 2

Open Peo­ple and groups to cre­ate a new group

Hide Recent 3

 

Step 3

Switch the view to Groups

Hide Recent 4

 

Step 4

Click “New” to cre­at the new group.

Hide Recent 5

 

 

Step 5

Give the new group a name and enter a descrip­tion.

Hide Recent 6

Should­n’t it say Group Descrip­tion or some­thing?

Leave all set­tings default and click “Cre­ate”.

Step 6

Delete your­self from the group

Hide Recent 8

If you cre­at­ed the group logged in with the sys­tem admin­is­tra­tive account the group will be emp­ty. 

 

Step 7

Go into Site set­tings and Nav­i­ga­tion

Hide Recent 9

And scroll down to Struc­tur­al nav­i­ga­tion

Step 8

Select the Recent head­ing and click on “Edit”

Hide Recent 10

 

Step 9

Edit the prop­er­ties for this Head­ing.

Find the new­ly cre­at­ed group by click­ing on the address book.

Hide Recent 11

Select “Share­Point Groups”

Hide Recent 12

Search, select, add and hit “OK

Hide Recent 13

 

If all went well you should see this screen. Just click “OK

Hide Recent 14

And now the Recent head­ing will be hid­den.

Hide Recent 15

Add extra result types and properties to the advanced search page

Step 1

First open the advanced search page.
This page can be found at <sitecollection>/search/advanced.aspx Result types 1

Step 2

Edit the page

Result types 2

Step 3

Edit the web­part

Result types 3

Step 4

Open the builder win­dow to edit prop­er­ties

Result types 4

Step 5

Once in the builder win­dow, select all con­tents by hit­ting CTRL‑A and copy it with CRTL‑C Result types 5

Step 6

Open Visu­al Stu­dio (or any oth­er edi­tor) and cre­ate a new XML file. We are not going to save this file but past­ing it into visu­al stu­dio for­mats the text so it is out­lined prop­er­ly. Result types 6

Step 7

Remove the default head­er. (CTRL‑A and DEL)

Result types 7

Step 8

And paste the XML from the web­part Result types 8

Looks much bet­ter does­n’t it?

Step 9

First we’ll cre­ate a new Result­Type Select the “Doc­u­ments” Result­Type. Copy and past it at the end of the Result­Types sec­tion.

Result types 9

Step 10

Rename “Doc­u­ments”. In this case we are going to use “Man­u­scripts” Result types 10

Step 11

Next we’ll cre­ate a new prop­er­ty def­i­n­i­tion Result types 11

Step 12

Add the new Prop­er­ty Def­i­n­i­tion to the new Result­Type Result types 12

Step 13

Copy all text and paste it back into the Builder win­dow in Share­Point Result types 13 And click OK

Step 14

Click OK to save the changes to the Web­part and save the page.

Result types 14

Don’t for­get to check in and pub­lish the page.

Et voila!

Result types 15

SharePoint 2013 Crawl job will not stop

When you are unable to stop a crawl (full or incre­men­tal) using the cen­tral admin, you can try these addi­tion­al steps.

  1. Stop and start the Share­Point Serv­er Search 15 ser­vice
    1. Do this by going into services.msc (Hit Win­dows, R and type services.msc)
    2. Find the ser­vice and hit restart
  2. Run this pow­er­shell script on your Share­Point serv­er

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

Get-SPEn­ter­pris­eSearchCrawl­Con­tentSource ‑SearchAp­pli­ca­tion “Search Ser­vice App” | ForE­ach-Object {
if ($.Crawl­Sta­tus ‑ne “Idle”)
{
Write-Host “Stop­ping cur­rent­ly run­ning crawl for con­tent source $($
.Name)…”
$.StopCrawl()
do { Start-Sleep ‑Sec­onds 1 }
while ($
.Crawl­Sta­tus ‑ne “Idle”)
}
Write-Host “Start­ing full crawl for con­tent source $($.Name)…”
$
.Start­Full­Crawl()
}

This should get things going again. ​