DailyStory PHP SDK

The DailyStory PHP SDK is an open source library hosted on GitHub used by PHP developers to integrate DailyStory's capabilities into their PHP application.

DailyStory Web Forms

DailyStory Web Forms enable you to create, design and manage web forms within DailyStory. You can then include those forms within your web application to request information from visitors, such as a signing up for a newsletter.

A web form is part of a DailyStory campaign and once a form is submitted the contents are used to either create a new lead within a campaign or add to an existing lead.

How to include a Web Form in PHP

To include a DailyStory Web Form in your existing PHP application, follow these steps:

  1. Get the PHP SDK Class Files

Include the PHP Class files in your PHP application. For DailyStory Web Forms you will need the dailystory_webform.php class file.

  1. Get your DailyStory Site Id

Find your DailyStory Site Id, as this will be required to use the PHP SDK. You can find your Site Id on the Tracking Code page in your DailyStory application. DailyStory Site ID and Tracking Code page

  1. Get your DailyStory Web Form ID

Next, get the Unique Id of the DailyStory Web Form you want to include. You can find your Web Form Unique Id by clicking on any Web Form.

Web Form Unique Id

  1. Call the WebForm API

Open or create a PHP page and include the dailystory_webform.php class. Next, create an instance of the DailyStoryWebForm object and call its renderWebForm method passing in your DailyStory Site Id and Web Form Id:


// Create an instance of the web form
$webform = new DailyStoryWebForm();

// Get the web form
echo $webform->renderWebForm($siteId,$formId);

Replace $siteId and $formId are the values from your DailyStory application from step 2 and step 3.

When you run this page, you should see something similar to this:

Simple Web Form

Next, let's add some simple style and JavaScript to improve this web form.

Read more details about styling your web form

To make things simple, DailyStory uses Bootstrap class names in the CSS. While not required, this means that you can quickly use the Bootstrap framework to immediately make your form responsive and adaptive (i.e., mobile friendly).

DailyStory also provides an optional JavaScript library that automatically takes care of things like Google reCAPTCHA support (when enabled) and client-side form validation.

Important - the optional JavaScript library provided by DailyStory requires jQuery.

Finally, DailyStory additionally provides some pre-built CSS files to add form validation and basic styling. These are completely optional:


// Create an instance of the web form
$webform = new DailyStoryWebForm();

// Get the web form
$form = $webform->renderWebForm($siteId,$formId);
	<script src="https://code.jquery.com/jquery-3.2.1.min.js"
    <script type="text/javascript" src="https://cms-1.dailystory.com/Scripts/ds-landingpages.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" id="ds-webform-css" href="https://cms-1.dailystory.com/Content/base_webform.css?ver=1.0.2" type="text/css" media="all">
<h1>Hello world!</h1>
<?php echo $form?>

Now our web form looks a little nicer:

Simple Web Form

There are several pre-built CSS templates to choose from. For example, if you want a simple horizontal form you can replace the base_webform.css with base_webform-horizontal.css and change the Web Form Layout to Hide Form Labels:

Simple Web Form

If you are actively testing a webform or make changes you can invalidate the PHP web form file cache by include __dsCache=refresh in the URL of any page that is rendering a web form.

More Examples

If you would like to see more examples please see our PHP examples in the SDK.