Event Tracking in Google Analytics with SharePoint Online

Google Analytics enables you to optimize your advertising ROI and track your sites and applications. It helps you get a better understanding of your business’ stakeholders. Google analytics brings with it open-source tools to analyze data for your applications.

Event-Tracking in Sharepoint online

Setup Google Analytics tracking

First and foremost you would need to set up a Google Analytics account before you move into SharePoint development.

  • Sign into your Google Analytics account through the URL: https://analytics.google.com/analytics/web/
  • Enter a valid email address and password. Click Next.
  • Click on the Admin tab on the left bar.
    Google Analytics Admin Tab
  • If you already have an account, select an account or click on Create Account to create a new one.
    Create account in Google Analytics
  • In case of a new account, provide Account Name, Website Name, Website URL and other required information, and click on Get Tracking ID. If you already have an account, select an account from the menu and under Property tab, go to Tracking Info > Tracking Code.
    Google Analytics Tracking Code
  • Note the Google Site Tag (gtag.js) tracking code for future use.
    Google Analytics Tracking snippet
  • Copy and paste below code snippet after the

Tracking code snippet

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID">//<![CDATA[//]]>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_TRACKING_ID');

Where, GA_TRACKING_ID = Google Analytics tracking id

  • Visit your site to verify that tracking code is working as expected and that you are being actively tracked.

Verify google analytics code

Event in Google Analytics

In terms of Google Analytics, an event can be described as the interaction of users with the content of a web page that is being tracked in GA. Content includes an image, a form, a button, a video, a gadget, an external link and much more.

Some of the examples of events/activities that can be tracked in GA include:

  • Downloading of a file
  • Clicking on a button
  • Visit on a dynamically generated page
  • Clicking on an image
  • Mouse movement
  • Playing a video
  • JavaScript load
  • Filling a form

Track Google Analytics custom events with SharePoint

It has now become a necessity to understand and analyze the interaction of users with the published content. Having Google Analytics as a tool to monitor your intranet is the way to go.

It provides an in-depth analysis of every bit of movement happening in your site along with concise real-time reports, widely used for public facing sites. Though it tracks company SharePoint intranets too.

You can use the gtag.js event command on the page where the tracking code has been set up.

gtag event command

gtag('event', <action>, {
'event_label': <label>,
'value': <value>
  • – string specifying the type of event appearing as event action in GA reports
  • – name that you provide as a way to collaborate similar objects tracked as event category in GA event reports
  • – non-negative integer to a tracked page element appearing as event value

Event Tracking command example

gtag('event', '<user display name>', {
'event_category': 'Download',
'event_label': '<Document Name>'

The above command fires Google Analytics event command having action ‘’, category ‘Download’ and label set as ‘’.

Send non-interaction events

Non-interaction = Boolean parameter passed to the event command that sends Event hit. It enables you to define bounce rate for pages including event tracking code.

In order to send a non-interaction event, pass the non_interaction parameter as true

Non-interaction parameter

gtag('event', 'video_auto_play_start', {
'event_label': 'Promotional video',
'event_category': 'video_auto_play',
'non_interaction': true

Track file downloads on your page using Google Analytics

An enhancement to Google Analytics is its ability to catch events fired from the site page.

Google Analytics makes use of client-side scripting to record user events or interactions such as File Downloads or External Links click. It helps to track events on all pages of the site irrespective of programming language.

By default, Google Analytics with SharePoint Development will not track how many times users have downloaded files and which users download which files (because the files fail to request much-needed tracking pixel).

Supposedly, you need to track file downloads, may it be a .pdf, .doc, .ppt, .pptx, .mp3, .xls, .zip – many more. The ideal approach is to track file downloads as events.

Track file downloads as custom events

If the users have the facility to download a lot of files on your page, SharePoint developers can just automate the process for download tracking rather than adding the code each time a button/link is clicked for download.

The below code provides a similar functionality. Place the code inside the ready function of the .js file on your page. You can customize the code based on your needs.

Track file downloads

var filetypes =
var baseHref = '';
if ($('base').attr('href') != undefined) {
baseHref = $('base').attr('href');
$('.search-listing').on('click', 'a[title="Download"]', function (event) {
var el = $(this);
var track = true;
var gaMaterialName = $(this).closest('li').find('em').attr('title');
var href = (typeof (el.attr('href')) != 'undefined') ? el.attr('href') : "";
if (!href.match(/^javascript:/i)) {
var elEv = []; elEv.value = 0, elEv.non_i = false;
if (href.match(filetypes)) {
var extension = (/[.]/.exec(href)) ? /[^.]+$/.exec(href) : undefined;
elEv.category = 'Download';
elEv.action = _spPageContextInfo.userDisplayName;
elEv.label = gaMaterialName + " - " + href.substr(href.lastIndexOf('/') + 1);
elEv.loc = baseHref + href;
track = false;
if (track) {
gtag('event', elEv.action, {
'event_category': elEv.category,
'event_label': elEv.label,
'value': elEv.value,
'non_interaction': elEv.non_i

The above script automates the process of file downloads and registers downloads as events inside Google Analytics. It works for the provided extensions: .zip, .exe, .dmg, .pdf, doc.*, xls.*, ppt.*, .mp3 and many more.

The event command specifies

  1. Event Action > Display name of the user downloading the file
  2. Event Category > Download
  3. Event Label > Name of the document – Filename with extension
  4. Event Value  > 0
  5. Non-interaction >  false

Note: Call the jQuery library from the google cdn before executing the above code.

After publishing the page, once user downloads a file, you can track the download in Google Analytics. Navigate to Real-Time > Events > Under Content, Events (Last 30 min).

Google Analytics Event Tracking

When you click on Download, you can view Event label

Download Event label

Remote Administration of SharePoint with PnP-PowerShell

From the title of the blog, the first question comes in mind is “What is PowerShell?”

The answer is: It is an object-oriented automation engine and scripting language developed by Microsoft and built on the .Net framework. It has an interactive command-line shell where the user can execute commands to fulfill their tasks.

It’s mainly used in configuring systems and automate administrative tasks. Actually, PowerShell and PnP-PowerShell scripts are highly used by SharePoint administrators and SharePoint developers can run large and bulk operations on sites. For example, add large data in SharePoint lists, apply permissions to users in sites, etc. Below scenario is often concluded while SharePoint consulting.

PnP PowerShell


For on-premise servers: Sometimes client provides SharePoint administrator access of site but without remote desktop access connectivity so we cannot take RDP session to run PowerShell scripts for managing SharePoint sites. In this case, we can log in to one of the client’s machines which are connected to SharePoint farm domain and after that, we can run PnP-PowerShell cmdlets for SharePoint site management which is not possible with conventional PowerShell scripts.

PowerShell scripts are based on the .Net framework so for execution, they are highly dependable on Microsoft OS versions where PnP-PowerShell is platform independent which means the user can run cmdlets from their Mac or Linux machines to manage SharePoint sites.

SharePoint administrators majorly use PowerShell scripting to manage SharePoint servers. Authorized administrators can perform a wide variety of operations in SharePoint On-premise and SharePoint Online by executing cmdlets (pronounced “command-lets”).

Microsoft provides cmdlets for these 2 systems:

The SharePoint Development Community

Commonly known as “SharePoint PnP Community” (PnP stands for Patterns and Practices) which is an open source initiative coordinated by the SharePoint engineering team. This community controls documentation, reusable controls and samples related to SharePoint development. Enthusiast developers or users can contribute their efforts in this community via GitHub. It is community driven open source project where Microsoft and external members can share their learning and implementation practices for Office, Office 365 and SharePoint servers. It was first started with guidance in the SharePoint add-in model and then evolves with other areas like SharePoint framework, Microsoft graph API, Office add-ins and Office 365 APIs.

Let’s talk about PowerShell commands prepared by the PnP community commonly known as PnP-PowerShell.


Microsoft has already provided a library of PowerShell commands for SharePoint On-premise servers and SharePoint Online along with separate command-line Shell. The question appears in mind that “What is PnP-PowerShell and what is the use of it?

SharePoint Patterns and Practices contains a library of PowerShell commands to ease the life of SharePoint administrators who can perform complex tasks in minutes with the new PnP PowerShell commands. These commands use CSOM and work for both SharePoint Online and SharePoint On-premise servers.

Most amazing and facilitating feature of PnP-PowerShell is cross-platform execution. PowerShell cmdlets used for SharePoint before were Microsoft OS dependent but now, you can use PnP-PowerShell with different platforms like Mac and Linux.

One of the benefits behind CSOM commands for SharePoint On-premise servers is that an administrator can use cmdlets without logged-in to servers which means the administrator can access servers from any machine’s PowerShell command prompt which is connected with same domain in the same farm.

PnP-PowerShell provides something we can call “Context Switching”. For example, you are connected to the SharePoint Online site. Now you want to do some admin side operations. With old SharePoint Online cmdlets, you need to first close the connection for the current site and after that, you need to create the context to connect to admin site using different URL (i.e.: https://admin.sharepoint.com). With PnP-PowerShell cmdlets, you can easily connect to admin site without creating the new context or closing older context.

PnP-PowerShell cmdlets:

Connect-PnPOnline https://contoso.sharepoint.com

Using the 1st line, you are connected to the SharePoint Online site. In 2nd line, you get all lists from the site. And using the 3rd line, you are now connected to SharePoint admin site.  It creates a clone of context during execution of the 3rd line, to use further in operations. So there is no need do new connection for admin site using commands.

Let’s start installation without wasting much time.



  • If you are using Windows Server 2012 R2 OS. Normally, this OS has PowerShell version 4. You require to upgrade PowerShell to version 5. Kindly download setup file from below URL to upgrade PowerShell:  https://www.microsoft.com/en-us/download/details.aspx?id=54616
  • You need to be a local administrator to run PowerShell as an administrator.
  • Set execution policy to allow to run remote scripts.


  • Run get-executionpolicy PowerShell command to get status of execution policy as shown below:Run get-executionpolicy
  • If it’s not set to “Remote signed”. Then set it by this command:
    set-executionpolicy remotesignedSet-executionpolicy remotesigned
  • Need appropriate permissions in SharePoint Online or in SharePoint server.

    Note: After performing the required operations through PnP cmdlets, set the execution policy from “Remote signed” to the original one i.e. the output of the get-executionpolicy cmdlets.

Install Setup

First approach: PowerShell Gallery

If your main OS is Windows 10, or if you have PowerShellGet installed, you can run the following commands to install package according to your environment need:

SharePoint Version

Command to

SharePoint Online


SharePoint 2016


SharePoint 2013


Here are some warnings or error messages with workarounds you might face during installation:

  • Sometimes for On-premise servers, if it gives below warning:

    Warning: user declined to install untrusted module SharePoint PNP PowerShell

    Use “-Force” attribute after the command:

    e.g.: Install-Module SharePointPnPPowerShell2013 –Force

  • Error message: PackageManagement\Install-Package: The version ‘x.x.x.x’ of the module ‘SharePointPnPPowerShellOnline’ being installed is not catalog signed. Use below cmdlet:

    e.g.:  Install-Module SharePointPnPPowerShellOnline -SkipPublisherCheck -AllowClobber

Second approach: Setup files

Download setup files from releases. It will provide different setup file for SharePoint 2013, 2016 and SharePoint Online. Install it according to your server needs. After installation, you need to restart the open instance of PowerShell.

Third approach: Installation script

It will require at least PowerShell v3 installed in the machine. You can check the version of PowerShell by running $PSVersionTable.PSVersion.

To install the cmdlets you need to run below command, which will install PowerShell Package Management and modules from PowerShell Gallery.

Invoke-Expression (New-ObjectNet.WebClient).DownloadString('https://raw.githubusercontent.com/sharepoint/PnP-PowerShell/master/Samples/Modules.Install/Install-SharePointPnPPowerShell.ps1')

Install Updates

Every month a release will be available for cmdlets. You can install the latest updated version using below commands:

Update-Module SharePointPnPPowerShell*

You can check installed PnP-PowerShell versions with the following command:

Get-Module SharePointPnPPowerShell* -ListAvailable
| Select-Object Name,Version | Sort-Object Version –Descending



Getting Started

Connect to SharePoint Online site with PnP-PowerShell

  • Let’s connect to SharePoint Online Site with below command:
    Connect-PnPOnline –Url https://&lt;tenant_name&gt;.sharepoint.com –Credentials (Get-Credential)

    PowerShell Credentials

    Note: If you are using multi-factor authentication on your tenant, use below command:

    Connect-PnPOnline -Url https://&lt;tenant_name&gt;.sharepoint.com -UseWebLogin
  • You can see all cmdlets provided by PnP with below command:
    Get-Command -Module *PnPPowerShellOnline*



In 3.1.1809.0 version, there are 348 commands available to manage SharePoint Online.
Create one custom list and perform CRUD operations

  • Connect to site using above commands.

    Create custom list

  • Using below command, get all lists from SharePoint site.


  • Create new list with below command:
    $listName="NewPnPList"   New-PnPList -Title $listName -Url "NewPnPList" -Template GenericList -EnableVersioning


Create fields in new list

  • Using below commands, 2 fields will be created in list:
    Add-PnPField -List $listName -DisplayName NameHF -InternalName NameHF -Type Text -AddToDefaultView
    $choices="Sofware Developer","Sofware Tester","Release Manager"
    Add-PnPField -List $listName -DisplayName RoleHF -InternalName RoleHF -Type Choice -Choices $choices -AddToDefaultView



NewPnPList Output.png
Create new item in list

  • Create new item using below command:
    Add-PnPListItem -List "NewPnPList" -Values @{"Title" = "Test 1"; "NameHF"="Name 1"; "RoleHF"="Software Developer"}



Create new Item

Update existing item

  • Update title of existing item using below command. Here, ID of list item is used for identity.
    Set-PnPListItem -List "NewPnPList" -Identity 1 -Values @{"NameHF" = "John Doe"}



Set-PnPListItem Output

Delete existing item

  • Delete list item using below command. Here, ID of list item is used for identity.
    Remove-PnPListItem -List "NewPnPList" -Identity 1



Remove-PnPListItem Output

SharePoint 2013 Variations

Huge organizations have many people working in the same organization in different regions across the globe having different languages for communication. In general scenario regional language is more in to preference. As internet facilities are now easily available, websites are the most favorable and less expensive equipment for marketing purpose. Websites should be capable enough to provide content suitable to their target audiences across the globe. But maintaining the different sites with different languages is very difficult for content redundancy point of view.

SharePoint 2013 Variations

According to Microsoft, many fortune 500 Companies are using SharePoint for public facing sites and as intranet sites to manage their businesses. They have many offices in different regions of the world. These types of company’s needs websites that deliver customized content, to suit different cultures and different markets. It is very tedious and time-consuming task to maintain and manage data with different languages. They have to make sure that data must be redundant. Therefore, Microsoft SharePoint has provided below approaches to manage multi-lingual sites:

  1. Install different language packs in SharePoint server: We can install different language packs in a SharePoint environment to support more than one language. But this will only affect the site administration pages and user interface but does not affect content created on site.
  2. Use the variations feature to make publishing content available in different languages on different sites: Different sites will be created for different languages and content will be sync between these sites. Unlike the first option, this feature does not affect the administration pages and user interface, only affects the content.

    Today, we will discuss for SharePoint variation features to manage content in multi-lingual sites. Points are insight by the team of SharePoint developers taking into considerations the real-time scenarios faced while the development phases and client requirements.

    We can use SharePoint variation feature to support multi-lingual sites in SharePoint server and SharePoint Online. Using Variation feature in SharePoint development, site administrators can simplify the process of maintaining these sites with different languages. It automates the creation, synchronization, and translation of sites, lists, and pages in SharePoint sites.

    When the user visits the root site, they are redirected to the appropriate variation site according to language settings in their browser settings. Variations can be utilized only on sites that are built by utilizing one of the Publishing site templates, or on sites for which the SharePoint Server Publishing Infrastructure feature was initiated.

Scenarios for using variations

We can manage variations to build and design sites, lists, and page content for specific linguistics. For example, the content might be accessible in English and be synced to target variation sites for translation into other languages say for example Arabic, German, French, and Spanish.

We can also use variations to create content for specific locales. For example, the Arabic language might have target variation sites for the following locales: Arabic (Egypt), Arabic (Qatar), Arabic (Saudi Arabia) etc. While SharePoint consulting, this is the general scenario commonly we came across with the clients.

The largest part of the content is authored in English (United States) in the general scenario, and the variation feature syncs that available content to the target variation sites.

Content on the French (Canada) and Dutch (Mexico) site are translated into French and Dutch, whereas content for English is edited to account for regional differences in Egypt and Qatar Arabic. Other content that is individual to a specific region is built on the target variation sites for which it is required.

In SharePoint 2010, we are using variations to create sites in different mobile devices, or that used different branding. In SharePoint 2016 based application development, variations are used only for multilingual sites. To create sites for different mobile devices in SharePoint 2016, we can use Device Channels. To create sites with different branding, we can use cross-site publishing.

Elements used in Variation features

The variations feature consists of the following elements:

  1. Variation Root Site: The variation root site is the source site of all the variation. Root site provides the URL for all source and target variation site and landing page URL to redirect in a specific variation site. Note: Variation root site is not the same as site collection root site, but we can set the site collection root site as a root site of variation hierarchy.
  2. Variation labels: A variation label is an identifier of a new variation site. We can create a variation site by creating/configuring the Variation label. Note: SharePoint Server supports up to 209 variation labels. SharePoint Online supports up to 50 variation labels.
  3.  Variations hierarchy: This is a hierarchy of all the Variations site with all variation label.
  4. Variation lists: Variation lists are lists where we specifically target variation labels to receive/sync list items.
  5. Variation pages: Variation pages are the publishing pages that are stored in the Pages library of the source variation site and the target variation sites. Important: Recommended that we do not add non-publishing pages to the Pages library of a site that uses variations. If we do that, the Variations Create Hierarchies Job Definition timer job might fail.
  6. Variation sites: Variation sites are the sites that are created based on the variation labels. There are two types of variation sites:
    1. Source variation site:The source variation site is the site where shared content is available and published, and it is the site from where the shared content is synced with target variation sites. There is only one source variation site per one site collection. Once we created a source variation site, it cannot be changed later.
    2. Target variation sites:The target variation sites receive/synced most of their content from the source variation site. We can add/update new content on a target variation site. However, that content is not synced with other sites and is individual to the site on which it was built.

Let’s start by configuring variation feature in SharePoint server:

Here, I have used SharePoint 2013 enterprise server for illustration purpose.

Variation Feature Prerequisites

SharePoint Variation feature requires below prerequisites:.

  1. Install required language packs on SharePoint server.Language pack on Sharepoint Server
  2. Configure Machine Translation service and make sure it is started in SharePoint Central Administration under “Application Management”.

    Manage services on server:

    Manage services on server

    Manage service applications:

    Manage service applications

  3. Require SharePoint site created using “Publishing” site template or site with “SharePoint Server Publishing feature” features activated.Sharepoint server publishing featureSharepoint server publishing

Configure Variations Settings

To Configure/Setup Variation in SharePoint site follow below settings:

  1. Go to Site Settings.
  2. Under “Site Collection Administration”, we can see the below variations settings are available:
    • Variations Settings
    • Variation labels
    • Variation logs
    • Translatable columns

    Site Collection Administration

  3. Go to Variations Settings.Variation Settings
  4. Here we have below self-explanatory settings are available, we can change these settings as per our requirements, else we can put these settings as it is.
    • Create Everywhere (Default): This option will propagate any content created in source label to all target variations.  Sync will happen automatically.
    • Create Selectively: This option will allow us to sync content to some but not for all target site. Variation should be triggered manually.
    • Recreate Deleted Target Page: This option will allow us to choose, whether a new target page should be recreated when the source page is republished, if the previous target page has been deleted.
    • Update Target Page Web Parts: This option will allow us to choose, whether Web Part changes from source page should be updated to existing target pages or not.  Note: Web Parts personalization will be lost when the update is made.
    • Notification: This option allows us to send an e-mail to the contact person of the welcome page of the target site when a new sub site or page is built, or the contact person of a page when a target page is refreshed with updates and alternatives from the source variation.

Create Variation Source Label

To create source variations site/label from where the content should be variant to the target site, follow the below steps:

  1. Go to Site Settings >Variation labelsNote: The very first variation label which we are creating will be the “Source Variation” site.
  2. Click on New Label.Variation Labels
  3. Let’s create English as a source site.
    • Language: This setting defines SharePoint User interface elements of the variation site. Options look on the site template language drop-down depends on the language sets installed.
    • Locale: Locale determines the language site based on our browser settings. Automatically it redirects the browser from Variation home to target variation site. Locale helps in creating content in different languages.
    • Variation Home: Location where the source and target variations will be created.
    • Label Name and Description: This name will be used to create the variation site and will appear in the URL. The name cannot be changed once the label is created.
    • Display Name: User-friendly, locale-appropriate name for the variation label.
    • Publishing Site Template: Select the site template that will be used to create top-level source and target variation sites.
    • Label Contact: If email notifications are enabled in variation settings, label contacts will receive emails when this source variation site is created.

    Create variation Label

  4. Click on “OK” to create source variation.
  5. Create Source variation

Create Variation Target Label(s)

To create target variations site/label, follow the below steps:

  1. Go to Site Settings > Variation labels > New Label.
  2. Let’s create Arabic as a first target variation site.
  3. Select Language and Locale, I have selected Arabic and Arabic (Qatar) respectively. Click on Continue.Configure target Label
  4. Enter appropriate variation Label Name, Description and Display Name. Select the portion of the source hierarchy we would like copied, this will be built label’s structure based on the source hierarchy during Hierarchy Creation. Click on Continue.Name your Target label
  5. Select appropriate Translation options.
    • Create Translation Package: Enabling human translation on this target will allow users to export content to an XLIFF file. Users may then transfer the file to a translator for professional translation.
    • Machine Translation: Enabling machine translation on this target will allow users to send content online to Microsoft for translation. We may use content users send us to improve the quality of translations.

    Translation options

  6. Click on Continue.
  7. Select appropriate Page Update Behavior from below and label Contact as per the requirements and click on Continue.
    • Users can manually sync updates from source variation pages: If the user doesn’t want to sync content from the source variation to target variation in that this option will be useful. For Example, In Source label pushed the content first time and target label authors translated the content to the target site, then later if user change in the source site but user don’t want to translate the later changes in the target site.
    • Automatically update target variation pages: If the user wants to translate the content automatically when user publish the content in the source site, it will automatically translate the change in the target label.

    Target Label Behavior

  8. Review and Click on Finish to complete target variation label creation.
  9. Review label Settings

    Variation Labels

Create Variation Hierarchy

Once we create a Label for source and target, each label should create a variation sub-site based on the scheduled timer job (i.e., Variations Create Hierarchies Job Definition) for the Variation.

Click on “Create Hierarchies” link from Variation labels page in site settings that will invoke the timer job “Variations Create Hierarchies Job Definition”. This timer job will get executed based on its schedule.

Create Hierarchies

Once the hierarchies created successfully, “Hierarchy is Created” status on Variation Label page will change to “Yes” and sites are created successfully.

Hierarchies Created

SharePoint 2013 Variation Timer Jobs

SharePoint 2013 Variation feature content synchronization is a unidirectional process, it synchronizes content from a source variation site to one or many target variation sites.

To see the Timer Job go to Central administration > Monitoring > Review Job Definitions.

Below are the list of timer jobs involved in variations feature in SharePoint:

  • Variations Create Hierarchies Job Definition: Creates all variation sites, lists and pages from the source variation site. It runs hourly.
  • Variations Propagate List Items Job Definition: Creates and updates list items on target variation Default, every 15 minutes.
  • Variations Propagate Page Job Definition: Creates and updates pages on target variation after approved. Runs every 15 minutes.
  • Variations Propagate Sites and List Job Definition: Implements or executes variation sites and lists when the “Create Everywhere” option is enabled.  The process executes every 30 minutes.
  • Variation Feature

Above timer jobs are run automatically at above mentioned time interval.

If user want to run any Timer Job manually for specific requirements, then user can find above timer jobs from Central administration > Monitoring > Review Job Definitions.

Select “Web Application” from the View as shown in below screenshot.

Job Definitions

Select our Web Application from Web Application Dropdown.

Select Web Application

Click on the appropriate timer job to run it manually.

We can see the Edit Timer Job page, Click on “Run Now” to start the timer job manually.

Edit Timer Job

Variation Logs

During the variation process, there are several timer jobs to execute for the task completion. All activities related to Variation process are logged and collected under Variation logs list to provide details and troubleshooting any variation related issue such as Hierarchy creation, Page propagation, etc.

Variation logs are positioned beneath root site collection’s settings page.

Site Settings > Site Collection Administration > Variation logs

Variation Logs

Test Variation Features

Let’s test Variation feature by Syncing Custom list and Libraries in Variation:

  1. Create new list and create one item on source English site.Variation Item List
  2. Now open the Variations tab from ribbon. And click on “Settings”. Select the target label and click on continue. We will provide “Your new variations are on the way” message. Click on OK.

    Create Variation

  3. New Variation Created

  4. This list and list item will be created based on the Timer Job Scheduled. Once Timer Job Run this list will be created on the target Arabic site as shown below:Note: We can also manually run the below Timer jobs from central administration to propagate changes on target site.
    • Variations Propagate Sites and Lists Job Definition
    • Variations Propagate List Items Job Definition
    • Variations Propagate List Items

Web Parts behavior with Variation features

Web Parts are synced with pages of variation sites. If “Update Target Page Web Parts” is allowed, web Parts are refreshed only on the target variation site if a page that incorporates that web part is synced to the target variation site.

If the web part seems on various target pages on many target variation sites, all instances of the web part are modernized when the page from the source variation site is synchronized to the target variation sites.

For illustration, if a page possesses a Media Web Part, and the web part is configured to point to “Video A” that is stored on a site outside the variations hierarchy when the page is declared on the source variation site, the page is synchronized to all target variation sites. The pages on the target variation sites exhibit “Video A” in the Media Web Part.

If the page on the source variation site is refreshed and the Media Web Part is modified to point to “Video B”, the pages on the target variation sites stretch to point to “Video A” until the page on the source variation site is declared and synchronized to the target variation sites. Also, if readers on the target variation sites do not have permission to view the video file that is stored outside the variations hierarchy, they can’t observe the video.


There are few limitations with Variation features in SharePoint Development:

  • We can use variation features only with the site(s) created using ‘Publishing site’ or ‘Publishing site with workflow’ templates. It is quite complicated to use feature stapling with OOTB site template for variation sites creation.
  • There can be only one root site variation per site collection.
  • There is only one way synchronization between the source language and target languages, we can synchronize content from source to target, but we cannot synchronize content from target to source.
  • Pages do not get synchronized until they are published. Therefore one version of the page has to be ready in source variation site before the target version of the page can even get translated and worked on.
How to Implement Remote Event Receiver in SharePoint Online

The scenario to deal with creating files in document libraries, adding/updating/deleting items in the SharePoint list, at times requirement emerges to perform some action on such events like sending notification, data manipulation on SharePoint lists or libraries, etc.

In SharePoint Development, there are two manners to achieve this – SharePoint Designer Workflow and Event Receivers. Of course we can use these techniques to achieve such requirement, but it runs on SharePoint server, i.e. business logic runs on the same server where SharePoint is installed, and event receivers do not support while working with Office 365 – SharePoint online. Few SharePoint programmers while consulting process may pitch to use different approaches like provider hosted-apps.

Cases where the business requirements are to keep business logic and SharePoint server segregated. Fortunately to deal with document libraries/lists on a host web (on which site we install application), it provides concept called Remote Event Receiver.If any list item is added/edited/deleted, and we want to perform any action like sending notification, we can use a remote event receiver.

So, let’s learn how to prepare provider hosted app and remote event receiver. We will host Provider Hosted application in Azure. Below are mentioned the steps to create remote event receiver.

Following are the tools to create remote Event Receiver:

  1. Visual Studio 2015
  2. SharePoint Online (Office 365)
  3. Azure Portal (For Deployment)

Step 1 – To Create Provider Hosted Application

  1. Open Visual studio
  2. Click on File  New Project.
  3. Dialog box will appear. Select Templates then Visual C# then Office/SharePoint.
  4. Select “App for SharePoint”, make sure .Net framework 4.5 is selected, for more information review below screen shot and give application “HelloWorldProvider” name.
  5. Open New project

  6. Then choose a SharePoint developer site and then choose Provider-hosted like below. You can see below article to know how we can create a developer site in SharePoint, for more information review below screen shot, for security reasons we have erased URL.
  7. New App for Sharepoint

  8. Then it will ask to give credentials for the developer site and then select SharePoint Online Version.
  9. Then wizard will ask which type of provider application, we want to create either Asp.Net web forms or ASP.Net MVC application. Currently, we will select ASP.Net web forms.
  10. On the next screen selection option “Use Windows Azure Access Control Service (for SharePoint cloud apps)”.
  11. It will take some time and it will create two projects in one solution, one is for the SharePoint add-in and the other will be ASP.NET web forms project, review below image for more information:
  12. Solution Explorer

  13. We need to attach event receiver to the list of host web (where we install add-in), so to achieve this, select add-in project from the solution and from the properties of the project set “Handle App Installed” to ‘true’:
  14. Set Solution Explorer

  15. After setting “Handle App Installed” property to true, AppEventReceiver.svc will be added inside the Services folder like below: We are going to write code to attach remote event receiver to host web’s list.
  16. App Event Receiver

Step 2 – To Add Remote Event Receiver to project

  1. Add Remote Event Receiver. Right click on the Add-in project then Add then New Item.
  2. Add Remote Event Receiver

  3. Give it name “Validation”.
  4. Saved as Validation

  5. Select List Item Events, event source as Custom List and then event as “An Item was added”, which means some action on the host web’s list will be performed when an item is added in that list.
  6. Choose Event receiver settings

  7. Validation.svc file will be added to add-in project as well as inside the service folder of the asp.net web forms project. Review below image:
  8. Validation.svc file

    Step 3 – To Generate Client ID & Client Secret

    1. To establish trust with the provider hosted web, we need to generate the Client ID and Client Secret. So navigate to the _layouts/15/appregnew.aspx page

      Example: https://test.sharepoint.com/sites/devsite/_layouts/15/appregnew.aspx

    2. Click on the Generate button for the Client Id and Client Secret fields to generate them respectively. Enter a title and in App Domain put the website that is created in azure (without https). Lastly, enter the Redirect URI which is the website URL, make sure to give in https.

      App Information

    3.  Open the web.config file and replace the Client Id and Client Secret which we have generated in the above page. Note: Before modifying the web.config file, take its backup.
    4. On AppManifest.xml, Right Click then View Code and add following code:
      <AppPermissionRequests AllowAppOnlyPolicy="false">
          <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="FullControl" />

      Also add client ID same as above

      Step 4 – To Add Code to AppEventReceiver

      In ASP.Net Web forms project inside the service folder’s AppEventReceiver.svc.cs file, we will add the code to attach the event receiver to the host list. The code will be added in the ProcessEvent event for the AppInstalled event.

      public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
      SPRemoteEventResult result = new SPRemoteEventResult();
      using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, useAppWeb: false))
      if (clientContext != null)
      if (properties.EventType == SPRemoteEventType.AppInstalled)
      //Get reference to the host web list with name Feedback
      var documentsList = clientContext.Web.Lists.GetByTitle("MDLIB");
      string remoteUrl = "https://customproviderhosted.azurewebsites.net/Services/Validation.svc";
      //Create the remote event receiver definition
      EventReceiverDefinitionCreationInformation remoteEventReceiver1ItemAdded = new EventReceiverDefinitionCreationInformation()
      EventType = EventReceiverType.ItemUpdated,
      ReceiverAssembly = Assembly.GetExecutingAssembly().FullName,
      ReceiverName = "ValidationItemAdded",
      ReceiverClass = "Validation",
      ReceiverUrl = remoteUrl,
      SequenceNumber = 10000,
      //Add the remote event receiver to the host web list
      catch (Exception ex) {
      SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("Remote Event Receiver - Error Report", TraceSeverity.High, EventSeverity.ErrorCritical), TraceSeverity.High, ex.Message, string.Empty);
      return result;

      Above code will attach remote event receiver to the list named “MDLIB” which will be in host web (i.e. where provider hosted app is going to be installed).

      Step 5 – To Add Code to Validation Remote Event Receiver

      In ASP.Net web forms project inside the service folder’s Validation.svc.cs file, we will add the code to instruct event receiver to updated description field of ‘MDLIB’ list when item added. The code will be added in the ProcessOneWayEvent event.

      public void ProcessOneWayEvent(SPRemoteEventProperties properties)
      if (properties.EventType == SPRemoteEventType.ItemAdded)
      using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
      if (clientContext != null)
      List lstDemoeventReceiver = clientContext.Web.Lists.GetByTitle(properties.ItemEventProperties.ListTitle);
      ListItem itemDemoventReceiver = lstDemoeventReceiver.GetItemById(properties.ItemEventProperties.ListItemId);
      itemDemoventReceiver["Description"] = " updated by remote event reciever =>; " + DateTime.Now.ToString();
      catch (Exception ex) {
      SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("Remote Event Receiver - Error Report", TraceSeverity.High, EventSeverity.ErrorCritical), TraceSeverity.High, ex.Message, string.Empty);

      Step 6 – To Deploy Provider Hosted App to Azure

      1. Right click on the asp.net forms web project and then click on Publish.
      2. Publish Web Project

      3. Public web project dialog will appear, click on Microsoft Azure Web Apps.
      4. Publish Microsoft Azure Web Apps

      5. It will ask to login into azure account, it will display all the web apps. Choose the particular web apps like below:
      6. login into azure account

      7. Publish method, Server, Site name, User name, Password and Destination URL will be appeared in next screen. Validate the connection and once it is successful.
      8. Publish method

      9. Click on the Next.
      10. Publish method Settings

      11. To verify all the files, you can also click on the Start Preview button to see the preview.
      12. Publish method Preview

      Step 7 – To Publish App Package

      Now asp.net web project is published to azure web portal, now it’s time to prepare package for the SharePoint add-in.

      1. Right-click on the Add-in Project and click on Publish.
      2. Publish Add in Project

      3. Publish your app page will appear, then click on the Edit button like below:
      4. Publish your app

      5. It will ask Client ID & Client Secret, write down both the same as we replaced into the web.config file.
      6. Set app identity

      7. Click on Package App, make sure that it is in release mode.
      8. Package App

      9. Here the website and Client Id will be populated by default. Click on Finish button which will generate the .app
      10. Finish Package the App

      11. It will open folder with package file (.app file).
      12. Open App Catalog site, go to Site Contents à Apps for SharePoint à Upload the .app file

      Reference Sites:

      1. App Catalog Site – https://docs.microsoft.com/en-us/sharepoint/use-app-catalog
      2. Create developer site – https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/create-a-developer-site-on-an-existing-office-365-subscription

      Step 8 – To Test Remote Event Receiver

      1. Go to site content of the developer site, and add an application.
      2. After the app is installed successfully, open the list and add an item to the list. Enter only Title and the Description will be added automatically by the remote event receiver like as shown below:
      3. .

      add an item to the list


      For the challenges part, there are few of them if the development is done using SharePoint Designer Workflow, but for Provider Hosted app it is way easier and safer as the business logic is not disclosed openly because it is hosted on separate individual server. Though details of each log can’t be maintained on the server as it is an individual server, yet the process is more streamlined and robust.

Enrich SharePoint Development with Chatbots

Terms like Chatbot, Artificial Intelligence and Personal Assistants are in trends since past few years. All major companies have initiated to incorporate such intelligent techniques in their respective business verticals. Like – more than 11,000 chatbots in Facebook messenger app, since April 2016 and many other examples are also available in the market.

Chatbots concept is growing as the latest standard of automation in the software development by simplifying the method for a user to receive desired information. Persona/avatar – Chatbot increases work productivity, offers information, boost ROI and decreases the searching time for B2C, B2B and B2E type of organization software solutions. Chatbot not only reverts back in text format but also in form of images, files, videos, etc.

Office 365 is emerging rapidly in Enterprises

“The cloud” allows to securely access web-based computing services that reside off-premises and are supported by the third party. The Advent of cloud era is looming nowadays as cloud-based services can be accessed virtually anywhere and on any device with an internet connectivity.

In this cloud era, Microsoft surprised enterprises and developers with Office 365. In Office 365, right from information storage to computation and software are maintained and established remotely on the secured servers possessed by Microsoft. Most recent features of Office 365 – SharePoint Development, Delve, Yammer and Dynamics 365, a Cloud-based solution, nowadays are availed by clients/organization to enhance business collaboration.

What does the future of SharePoint hold?

SharePoint would continue to be a very effective platform for business use and for many more. The enhancements only serve to boost the performance of the platform.

When it comes to the future of SharePoint Development, Microsoft would continue to provide on-premises version of the platform as long as there is market demand. Furthermore, Microsoft recognizes that on-premises would be around for some time, if not mostly in a form of hybrid environments.