Skip to main content

Viva Insights Sample Code Library

Sample code for Microsoft Viva Insights analytics

Templates, prompts, and tutorials in R and Python — from Copilot adoption and ONA to causal inference and AI-agent analytics.

Real code, ready to run

Working R and Python scripts built on the official Viva Insights packages.

Prompts that turn exports into decks

Paste a Frontier prompt into a coding agent and get a dashboard, exec summary, or ROI analysis.

Research-backed playbooks

Methodologies grounded in behavioural research — super users, causal inference, ONA.

Library overview

Browse the library by topic

Pick a category to find tutorials, utility scripts, and analytical playbooks for that area of Viva Insights analysis. Most scripts are written in R or Python, with dedicated vivainsights packages that handle the heavy data-processing work.

Is this library for me?

New to Viva Insights? Start with the Viva Insights Power BI templates and official documentation — they provide pre-built dashboards that deliver value without any coding.

Ready for advanced analysis? This library is for analysts, data scientists, and researchers who want to unlock deeper insights through custom analysis — predictive models, custom dashboards, hypothesis testing, ONA, Copilot impact measurement, or scaled automation.

Sample code

Special focus areas

Two areas where this library goes deeper than the standard packages: measuring Copilot adoption and impact, and using AI coding agents to turn raw Viva Insights exports into finished outputs.

Copilot analytics

With the rapid adoption of Microsoft Copilot, understanding usage patterns and measuring impact has become critical. Our dedicated Copilot Analytics section provides specialized scripts and methodologies for:

  • Measuring Copilot adoption rates and user segmentation
  • Identifying power users and building habit-based usage models
  • Analyzing productivity impact and ROI of Copilot investments
  • Creating executive dashboards for tracking deployment success

Frontier — AI-agent analytics

As organizations move from measuring Copilot adoption to measuring the impact of AI agents, a new class of analysis is required. Our Frontier section turns a Viva Insights export into a finished dashboard, executive deck, or ROI analysis by pasting a ready-made prompt into a coding agent. It provides analyst prompts, schema guides, and worked examples for:

  • Profiling agent and Copilot usage across the organization
  • Estimating the ROI and time savings of AI investments
  • Building executive summaries, dashboards, and PowerPoint-ready outputs
  • Validating findings against the underlying Copilot/agent data taxonomy

Quick links

Research & articles

Long-form reading and methodology

Editorials, research briefs, and how-to guides on meeting culture, Copilot adoption, super-user research, and AI-enabled collaboration practices.

Browse the full Articles index for editorials and research briefs, or read on for how to use the rest of the library.

Built for data scientists

Most scripts here are written in R and Python — the most popular languages for automation, experimentation, and advanced statistical analysis. To accelerate your work, we've developed dedicated packages that handle the complexities of Viva Insights data processing:

These packages let analysts hit the ground running without writing data-processing code from scratch.

How to use this library

Each script includes:

  • Purpose — what the script accomplishes
  • Prerequisites — required packages and data formats
  • Usage — how to run and customize the code
  • Download — direct link to the raw script file

Contributing & license

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA). For details, visit Microsoft CLA. The project is licensed under the MIT License — see the LICENSE file for details.