Dave Burrell
  • Home
  • Power Automate
  • Power Platform
  • D365
  • Solution Architecture
  • Lifestyle
  • About Me
  • Contact Me
Top Posts
Solution Framework Fundamentals
Working from home – How to survive!
Power Automate Patterns: Scottish Summit 2020
PowerObjects: One Year Aniversary!
Dynamics365 / CDS – Five Layers of Security
Solution Strategy
Integration Demystified
#COMMUNITYROCKS – Virtual Lunch
PSA is Dead – Long Live Project Operations
Updates Delayed
Dave Burrell
  • Home
  • Power Automate
  • Power Platform
  • D365
  • Solution Architecture
  • Lifestyle
  • About Me
  • Contact Me
AzureDynamics 365

ClickDimensions – Middle Ware

by Dave Burrell 14th January 2019
by Dave Burrell 14th January 2019
0
FacebookTwitterLinkedinRedditWhatsappEmail

This is an expansion on my previous post about the ClickDimensions Cookie Challenge. ClickDimensions is an excellent addon for Dynamics 365 though when it comes to form capture, it lacks what I feel is a fundamental function. Out of the box when a form is submitted the system is only capable of redirecting the end user to either a success or failure page, while this works well for contact us forms it is not as suitable for the likes of a whitepaper download where you want to redirect the user to a specific page based on the context of the form.

To resolve this issue, I created an Azure web app middleware that sits between the website form and ClickDimensions which allows a logic layer and provides far more control on where to redirect the user.

ClickDimensions – Middle Ware click1

The middleware effectively acts as a buffer between the website and ClickDimensions. By intercepting the response from ClickDimensions, we can control where the user is redirected to.

ClickDimensions – Middle Ware click2

In this example code, I have used a hidden field on the form to allow the website to pass over the redirect URL to the service. The other option would be to code the redirect logic directly into the Azure App. The method used here give you far more control as it is easier to pass the URL as part of the web form opposed to coding the logic into the application.

Another area to note is that this code has a honeypot field built in to reduce the risk of spam. On each of the form, a hidden field should be created called hp. A real end user will never even know the field exists, but a robot will pick this up as a field to be filled in. This reduces the risk of a bot attack dramatically. I would however still recommend implementing recaptcha.

I have included a link to the sample code on GitHub. The area to note is the mechanism to capture the response from ClickDimensions. For this I have used the stream code below:

        private string PostToServer(string FormCaptureURL, string PostData)
        {
            try
            {
                string serverResponse = String.Empty;

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(FormCaptureURL);
                // Set the Method property of the request to POST.
                request.Method = "POST";
                // Create POST data and convert it to a byte array.
                byte[] byteArray = Encoding.UTF8.GetBytes(PostData);
                // Set the ContentType property of the WebRequest.
                request.ContentType = "application/x-www-form-urlencoded";
                // set referer
                request.Referer = Properties.Settings.Default.Referrer;
                // Set the ContentLength property of the WebRequest.
                request.ContentLength = byteArray.Length;
                // Get the request stream.
                Stream dataStream = request.GetRequestStream();
                // Write the data to the request stream.
                dataStream.Write(byteArray, 0, byteArray.Length);
                // Close the Stream object.
                dataStream.Close();
                // Get the response.
                WebResponse response = request.GetResponse();
                // Get the stream containing content returned by the server.
                dataStream = response.GetResponseStream();
                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader(dataStream);
                // Read the content.
                serverResponse = reader.ReadToEnd();
                // Clean up the streams.
                reader.Close();
                dataStream.Close();
                response.Close();

                return serverResponse;
            }
            catch
            {
                throw;
            }
        }

Effectively this reads the website response from ClickDimensions as if it was a user on the browser. The redirect contains a single line of text of either success or failure which the stream code reads and redirects accordingly.

ClickDimensions – Middle Ware github middleware 1024x488
Click to open GitHub project.

AzureClickDimensions
0
FacebookTwitterLinkedinRedditWhatsappEmail

Leave a Comment Cancel Reply

Save my name, email, and website in this browser for the next time I comment.

Dave Burrell

Hey! I am Dave Burrell a Power Platform Solution Architect. I am an evangelist for all things Power Platform and love nothing more than a #LowCodeNoCode implementation.

previous post
Dynamics 365 April ’19 – Key Dates
next post
MSE and Insideview: The end is nigh

You may also like

ClickDimensions Cookie Challenge

2nd January 2019

About Me

About Me

Power Platform Evangelist

Hey! I am Dave Burrell a Power Platform Solution Architect. I am an evangelist for all things Power Platform and love nothing more than a #LowCodeNoCode implementation.

Lets be Social!

Facebook Twitter Instagram Linkedin Youtube Email

Quote

Revolutions begin with Community!

Recent Posts

  • Lack of updates and something exciting…. 10th April 2020
  • Updates Delayed 24th March 2020
  • #COMMUNITYROCKS – Virtual Lunch 17th March 2020
  • Working from home – How to survive! 16th March 2020
  • PowerObjects: One Year Aniversary! 13th March 2020

Microsoft Community Posts

  • Sending a Reminder Email from a SharePoint List

    Learn how to send reminder emails based on a date in a SharePoint list.

  • Flow with "When an item is created or modified" triggers old events

    When you create a flow with SharePoint trigger like "When an item is created or modified", you want […]

  • Share Multiple Attachments of SharePoint List via Email using Power Automate

    Share Multiple Attachments via Email in few steps using Power Automate

  • Comparing the members of a distribution list to the members of an Office 365 group or Team

    Analyze the members of a distribution list which is populated by an HR process and automatically […]

  • Power Automate - Format Phone Number Easy

    Take a phone number like 4031234567 and turn it to (403)-123-4567 with one simple step! 

  • Facebook
  • Twitter
  • Instagram
  • Linkedin
  • Youtube
  • Email

@2020 - All Right Reserved. Designed and Developed by Dave Burrell


Back To Top
This website is using cookies. We use them to give you the best experience. If you continue using our website, we'll assume that you are happy to receive all cookies on this website.OkPrivacy policy