HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In
GitHubNuGetDev CommunityDoc feedback

(Thanks to [Henrik Fransas at NetRelations](🔗) for this example.)

In Optimizely you can create custom reports and use the built-in reports in the admin view. The following example shows how to create a custom report of existing pages on a website and how to export the report to Excel using EPPlus.

  1. Start by creating a Controller that looks like this:


    This controller is a GuiPlugin which is shown in the report menu and uses the URL _/existingpagesreport_. The controller is protected so you have to be part of the administrator group to use it.

  2. For the URL to work, add a route to it in _global.asax.cs_:


    Create a simple view and make sure it shows up in the report center.

  3. Add a ViewModel with the necessary properties:

  4. Create a helper class to make a request against Optimizely like this:

  5. Update your index action to create an instance of the View model and assign all page types to it:

  6. Create a view and add Optimizely's CSS and JavaScript to it to have the same look-and-feel as other built-in reports in Optimizely. The complete view looks like this:


    This code has two **Submit** buttons but only one form action; the JavaScript function connected to the click event on the export and search submit buttons updates a hidden value telling the controller to do an export of the data or not.

    The action in the controller that handles this looks like this:


    It returns the view if the export values are not **true**.

  7. To export the report to Excel, use **EPPlus** and create a function in the same class like this: