README.md 4.07 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
## Matomo Tag Manager for SharePoint 2013/2016/2019/Online

This solution demonstrates how to implement Matomo Tag Manager in Microsoft SharePoint 2013/2016/2019 On-Premises or SharePoint Online using the PowerShell script SPMTM.ps1, and also provides you the capability to enable a Tag Management System for a Site Collection.

### Setup Instructions

In order to set the solution up on a target Site Collection, you simply need to:
* [Download the files included in this solution](#download)
* [Setup software requirements](#requirements)
* [Execute the *SPMTM* script](#execute)

>**Note**: If you are using SharePoint 2013 environment, setup scripts are assuming that you are running at least the April 2015 CU.

<a name="download"></a>

#### Download the files

You can download the files manually, one by one, or you can download as ZIP the repository with all custom actions. Within the ZIP archive, under the `/SharePoint.MTM` folder, you will find all the required files.

<a name="requirements"></a>

#### Setup software requirements

This solution requires the SharePointPnP.PowerShell commands, which you can install from one of the following link, depending on your target platform: 
(see the [SharePointPnP.PowerShell installation instructions](https://github.com/OfficeDev/PnP-PowerShell#installation) for further details): 

* [SharePointPnP.PowerShell package for SharePoint 2013](https://github.com/SharePoint/PnP-PowerShell/releases)
* [SharePointPnP.PowerShell package for SharePoint 2016](https://github.com/SharePoint/PnP-PowerShell/releases)
* [SharePointPnP.PowerShell package for SharePoint Online](https://github.com/SharePoint/PnP-PowerShell/releases)

>**Note**: Depending on your target platform (SharePoint 2013/2016/2019 On-Premises or SharePoint Online) you should refer to
the right build of the SharePointPnP.PowerShell commands. Nevertheless, even the SharePointPnPPowerShellOnline version, which
targets SharePoint Online, is viable to setup this solution on-premises. If you are running SharePoint 2013 environment, 
PowerShell cmdlets used by the automation scripts have dependency on April 2015 CU to be installed on server side. 

<a name="execute"></a>

#### Execute the *SPMTM* script

Once you have installed the SharePointPnP.PowerShell commands, you can open a PowerShell console, go to the path where you stored the files and execute the *SPMTM.ps1* script.

The *SPMTM* script accepts the following parameters:

| Parameter | Required | Default value | Description |
|-----------|----------|---------------|-------------|
| `-siteUrl` | yes | `undefined` | URL of the site to provision and/or enable the custom action |
| `-trackingUrl` | yes | `undefined` | Matomo Tag Manager URL |
| `-Credentials` | no | `undefined` | User credentials that will be used to authenticate against both the target Site Collection. Should be the credentials of a user, who is Site Collection Administrator for the target Site Collections. If you don't provide this parameter, the script will directly prompt you for credentials. |

You can here see a couple of examples about how to invoke the *SPMTM* script:

##### EXAMPLE 1

> Change *https://matomo.my-domain.com/js/container_[contrainer ID].js* in accordance with your environment.

```PowerShell
PS C:\> .\SPMTM.ps1 -siteUrl "https://intranet.mydomain.com/sites/targetSite" -trackingUrl https://matomo.my-domain.com/js/container_[contrainer ID].js
```

The example above enables the Matomo Tag Manager on the target Site Collection with URL https://intranet.mydomain.com/sites/targetSite.

The user's credentials are not provided, the script will therefore directly prompt the user.

##### EXAMPLE 2

> Change *https://matomo.my-domain.com/js/container_[contrainer ID].js* in accordance with your environment.

```PowerShell
PS C:\> $creds = Get-Credential
70
PS C:\> .\SPMTM.ps1 -siteUrl "https://intranet.mydomain.com/sites/targetSite" -trackingUrl https://matomo.my-domain.com/js/container_[contrainer ID].js -Credentials $creds
71 72 73
```

The example above enables the Matomo Tag Manager on the target Site Collection with the user's credentials provided through the *$creds* variable.