Unstoppable Domains, a platform for user-controlled digital identity on Web3, recently announced the global launch of Login with Unstoppable, an NFT single sign-on service for Ethereum and Polygon. Login with Unstoppable allows people to share data, such as email addresses, non-fungible tokens (NFTs), and off-chain information, with applications they use, all using an Unstoppable domain.
How To Use SingleStore Pipelines With Kafka, Part 2 of 3
Abstract
In this second part of our Pipelines series, we'll write some Java code to simulate our sensors sending temperature readings. We then store these readings in a SingleStore database. A Producer application will generate and send the temperature readings to the Confluent Cloud. A Consumer will then read these values from the Confluent Cloud and connect to SingleStore using JDBC, where the sensor readings will be stored in our temperatures table.
The SQL scripts, Java code, and notebook files used in this article series are available on GitHub. The notebook files are available in DBC, HTML, and iPython formats.
Detecting and Solving Segmentation Faults in Linux Containers
Understanding and solving errors are essential skills for any Linux administrator. The most common errors you will get are: “no such file or directory found” or “unable to access or permission denied”. If you are a Linux administrator, it is mandatory to know how to detect and solve segmentation faults. In this article, we will explain what segmentation fault is, what causes them, and how to detect or troubleshoot them. So let’s get started.
What Is a Segmentation Fault?
A segmentation fault is nothing but the error that occurs due to failed attempts to access Linux OS’s memory regions. These types of faults are detected by the kernel. Once detected, the process is immediately terminated, and a “segmentation violation signal” or “segmentation fault” is issued.
A Practical Tip For Using Sass Default Parameters
Sass offers functions and mixins that accept parameters. You can use Sass default parameters, that is, parameters that have a value even if you don’t provide them when the function or mixin is called.
Let’s focus on mixins here. Here’s the syntax of a mixin:
@mixin foo($a, $b, $c) {
// I can use $a, $b, and $c in here, but there is a risk they are null
}
.el {
@include foo(1, 2, 3);
// if I tried to do `@include foo;`
// ... which is valid syntax...
// I'd get `Error: Missing argument $a.` from Sass
}
It’s safer and more useful to set up default parameters in this Sass mixin:
@mixin foo($a: 1, $b: 2, $c: 3) {
}
.el {
// Now this is fine
@include foo;
// AND I can send in params as well
@include foo("three", "little", "pigs");
}
But what if I wanted to send in $b
and $c
, but leave $a
as the Sass default parameter? The trick is that you send in named parameters:
@mixin foo($a: 1, $b: 2, $c: 3) {
}
.el {
// Only sending in the second two params, $a will be the default.
@include foo($b: 2, $c: 3);
}
A real-life example using Sass default parameters
Here’s a quick-y mixin that outputs what you need for very basic styled scrollbars (Kitty has one as well):
@mixin scrollbars(
$size: 10px,
$foreground-color: #eee,
$background-color: #333
) {
// For Google Chrome
&::-webkit-scrollbar {
width: $size;
height: $size;
}
&::-webkit-scrollbar-thumb {
background: $foreground-color;
}
&::-webkit-scrollbar-track {
background: $background-color;
}
// Standard version (Firefox only for now)
scrollbar-color: $foreground-color $background-color;
}
Now I can call it like this:
.scrollable {
@include scrollbars;
}
.thick-but-otherwise-default-scrollable {
// I can skip $b and $c because they are second and third
@include scrollbars(30px);
}
.custom-colors-scrollable {
// I can skip the first param if all the others are named.
@include scrollbars($foreground-color: orange, $background-color: black);
}
.totally-custom-scrollable {
@include scrollbars(20px, red, black);
}
I’m just noting this as I had to search around a bit to figure this out. I was trying stuff like sending empty strings or null
as the first parameter in order to “skip” it, but that doesn’t work. Gotta do the named parameter approach.
A Practical Tip For Using Sass Default Parameters originally published on CSS-Tricks. You should get the newsletter and become a supporter.
Intelligent data as a service (iDaaS) – Common architectural elements
In the previous article from this series we introduced an architecture around intelligent data as a service (iDaaS) for the healthcare industry.
The process was laid out how we approached the use case and how portfolio solutions are the base for researching a generic architecture.
Keep It Stupid Simple please
If you do a meta analysis on constructs such as SOLID, or any other architectural best practices, you'll easily see how there's another abstraction layer above these principles, arguably being the foundation of everything you do, which is KISS. KISS of course implies ...
Keep It Stupid Simple
Auto-Instrumenting Node.js Apps With OpenTelemetry
In this tutorial, we will go through a working example of a Node.js application auto-instrumented with OpenTelemetry. In our example, we’ll use Express, the popular Node.js web application framework.
Our example application is based on two locally hosted services sending data to each other. We will instrument this application with OpenTelemetry’s Node.js client library to generate trace data and send it to an OpenTelemetry Collector. The Collector will then export the trace data to an external distributed tracing analytics tool of our choice.
7 Useful Plugins for Adding Features to Contact Form 7
Contact Form 7 is a fantastic free plugin for adding contact forms to a WordPress site. But despite its ease of use and reliability, it’s missing a lot of features out-of-the-box.
I recently showed how you can style Contact Form 7 with the help of plugins. In this post, I’ll show you how to extend Contact Form 7 even further to do the following:
- Add conditional logic to your form
- Add dynamic values to your form fields
- Save contact form submissions to the WordPress database
- Send out a PDF generated from your form
- Protect your form from spammers
- Sell simple products without an eCommerce solution
All the plugins mentioned throughout this post are free to download from WordPress.org.
Let’s get started.
Tip: if you’re a WPMU DEV member, you can use our very own Forminator plugin as an alternative to Contact Form 7.
7 Useful Plugins for Adding Features to Contact Form 7
- Contact Form 7 Conditional Fields
- HubSpot
- Redirection for Contact Form 7
- Contact Form Submissions
- Send PDF for Contact Form 7
- Contact Form 7 Honeypot
- Contact Form 7 – PayPal Add-on
1. Contact Form 7 Conditional Fields
Contact Form 7 Conditional Fields brings conditional logic to your contact form. Form fields can be set to appear only when the user has given a particular response.
For this example, I created a question for a company contact form that collects some useful marketing information by asking the user how they heard about the company.
There are 5 options for that question:
- Word of mouth
- Search engine
- Social media
- Other
These options are added as radio buttons. My radio button group was named where
.
When the “Other” option is chosen, it should show a text field for the visitor to add the other method that they discovered us. I named this text field where-other
.
But this field should only show if the Other option is selected, so it’s wrapped in a conditional field group which uses the shortcode [group other][/group]
. My conditional field group is called other-input
.
To set the display condition go to Conditional fields and create a rule.
Here is the final contact form code for the radio button group and text field:
The form will now only show the option to add an additional response when Other is selected.
Remember to alter the message body under “Mail” to add the new information to the email you receive.
The [other-input]What other place? [where-other][/other-input]
line will only show the [where-other]
content when it’s been completed.
It’s also good practice to check the Exclude lines with blank mail-tags from output option. This stops any incomplete fields from being output in the email text.
2. HubSpot
HubSpot’s WordPress plugin will collect all of your Contact Form 7 submissions and organize them into a free CRM. This allows you to see all the pages your contacts have viewed, live chat with them while they are on your site, and send marketing emails to them, all for free.
HubSpot makes it really easy to manage all of your contacts and segment them into lists. All their information is captured into a tidy timeline so you can truly understand the people behind the forms.
With HubSpot’s plugin, you can save up to 1,000,000 detailed contact and company records, and send up to 2,000 automated emails for free.
3. Redirection for Contact Form 7
With the Redirection for Contact Form 7 by Qube One, you can redirect to any page you choose. You can also fire scripts after submission, save submissions in the database, and more:
- Redirect to any URL
- Open page in a new tab
- Run JavaScript after form submission (great for conversion management)
- Pass fields from the form as URL query parameters
- Add Honeypot to minimize spam
- Save form submissions to your database
Actions are simple to use. Choose the form you want, and go to editing mode. Select the Actions tab, and choose from the options in the dropdown menu.
For Redirect, after selecting it from the Choose Action dropdown menu, you’ll see it listed in the Actions panel, with the title New Action. Click on that to open it, then name your rule, select the URL redirect (custom or a page), and toggle any desired options in the settings page. Make sure to click the Save button when you’re done.
There is also a pro version, which adds quite a few additional features, along with associated fees. Some of these are: Conditional Logic of Actions, Hubspot Integration, Subscription to MailChimp, and Collect Payments (Stripe and PayPal). You can buy these individually, or as an Action Bundle.
The plugin allows easy free trial for many of the pro features from within its WordPress dashboard.
4. Contact Form Submissions
Contact Form Submissions saves all Contact Form 7 submissions to the database and allows you to export them to a CSV file as well.
This is a useful plugin, but be sure that you have good reason to collect and keep form data before using it. This applies especially if you are gathering personal data such as names and email addresses. Make sure you have a robust data protection policy and delete the data after it is no longer needed.
The plugin creates a new menu item called Submissions under Contact Form 7 where you will find your form entries.
Submissions are for all forms with the newest at the top. They can be reordered by date, but not by form.
If you use the Mail(2) setting to create an autoresponder when someone submits a form, these entries will also be shown in your submissions. Each shows below the email sent to you.
5. Send PDF for Contact Form 7
As you might guess, Send PDF for Contact Form 7 sends out a PDF when the contact form is submitted.
You configure it via Contact > Send PDF with CF7.
First, select the form you want to send the PDF with from the dropdown.
You now have quite a number of options:
- Email a PDF to the sender, recipient or both.
- Email a CSV file to the sender, recipient or both.
- Name the PDF file. You can include form tags in the name such as [name]. It’s a good idea to make the filenames unique.
- Choose whether files will be saved on the web server or deleted after sending. (Think about data protection!) Saved files go to / wp-content / uploads / * YEAR * / * MONTH * / You can change the destination folder.
- Redirect the user to a new page after the contact form is submitted.
- Add a link to download the PDF.
- Password protect your PDF file.
- Add an image header to your PDF.
- Add tags such as date, time and page number to the footer.
- Personalize your PDF layout, including the form tags. You can include files uploaded by users if you have enabled file upload on your form.
Here’s an example.
In my contact form, I’ve made use of hidden dynamic fields from the Contact Form 7 – Dynamic Text Extension plugin. I also embedded a Google map.
In the “Send PDF with CF7” options, here’s my template for the PDF:
To email a PDF to the person making the booking, you must have the Mail(2) autoresponder for the form enabled. The PDF is attached to the confirmation email.
Otherwise, enable the PDF download link when the form is submitted.
6. Contact Form 7 Honeypot
Problems with spammers? Then Contact Form 7 Honeypot is for you. It deters spammers without annoying users with fiddly CAPTCHAs or quiz questions.
The plugin creates a new [honeypot]
tag.
When the tag is added to the form it creates an invisible text field which is intended to be left blank. If the field is completed, the form submission is flagged up as spam.
Should the contact form be inspected or viewed without style, the invisible field shows a “Please leave this field empty.” message.
There are filter functions available to customize this message and the HTML and CSS of the honeypot.
7. Contact Form 7 – PayPal Add-on
Do you have a single product to sell and don’t want the hassle of setting up a full-blown eCommerce store? Then Contact Form 7 – PayPal Add-on may be for you.
The plugin integrates with your form to send the user to PayPal to make a payment.
Set your PayPal general settings at Contact > PayPal Settings. You will need to add your language and currency, add a PayPal account ID and choose between Sandbox or Live mode. Test your form in Sandbox mode before making it live.
I chose an example of a form for preordering an ebook which would be delivered on a future date.
Here’s what the order form looks like on the front-end:
To enable PayPal on the contact form check the box on the PayPal tab for that form. Enter the product information, which will be passed to PayPal.
When the user submits the form, two things happen:
- An email is sent to the person ordering the product.
- The person is sent to PayPal to pay for the item.
1. Sending the email
The wording of the email sent has to be careful, as the order isn’t confirmed until payment is made. The user might navigate away from the payment screen or cancel the order.
Here is the wording I came up with to be sent to the person who preorders:
Thanks for your interest in [productname], [your-name], <[your-email]>.
Your order is not confirmed until you have paid by PayPal.
When payment is confirmed, your order of [productname], ID [productid] costing [price] will be sent out after publication on September 30, 2017.
Again I used dynamic hidden fields from the Contact Form 7 – Dynamic Text Extension plugin.
2. Sending the user to PayPal to pay
This happens automatically when the form is submitted successfully.
The sequence is:
- The customer is prompted to log in if they are not logged in already.
- The customer reviews their order.
- The customer pays for the order and gets a payment confirmation screen and email.
On the Settings page, the plugin allows you to set a redirect URL in case of cancellation, as well as one for making a successful payment.
The Pro version of Contact Form 7 – PayPal Add-on offers more features which overcome some of these limitations:
- Send emails after payment is made.
- Sell up to 5 products per form.
- Link form items to PayPal fields.
- Charge shipping and tax.
Summing up
As you’ve just seen, Contact Form 7 isn’t just a mere contact form. It can be enhanced to do quite a bit more, from adding dynamic data to logging entries to taking online orders.
Hopefully, you’ve picked up some tips in this post to extend your own implementation of Contact Form 7 on your site.
Metrics and Logs Are Out, Distributed Tracing Is In
This post recaps my talk with Chinmay Gaikwad, the tech evangelist at Epsagon, about distributed tracing and observability for microservices architectures. Check out the transcript and video from our conversation below!
Question: Can you talk a little bit about what you do, where you come from and what's Epsagon famous for?
The Ultimate Guide on DB-Generated IDs in JPA Entities
According to the JPA specification, Entity
is a Java class that meets the following requirements:
- Annotated with
@Entity
annotation - Has no-args constructor
- Is not final
- Has an ID field (or fields) annotated with
@Id
As you can see, ID is required. Why is that?
8 Top Metrics for Measuring Your Technical Debt in 2022
Much like running up bills on your credit card, technical debt can easily get out of hand. To avoid this happening, you need to keep track of how much debt you’re building up.
Technical debt metrics are designed to help you make sense of all the data you collect. There are many different metrics to choose from nowadays, and plenty of tools for recording the data.
AWS CLI in 3 Minutes
The AWS Command Line Interface (CLI) is a tool for managing your AWS services. This is a quick video to teach you to install, configure and run some commands of the AWS CLI.
In the demonstration, you can see that some S3 bucket operations can easily be done with the AWS CLI.
Collective #694
Inspirational Website of the Week: Pinch
A clean design with beautiful micro-animations and some lovely typography art.
Instant websites for your clients with Divi Layout Packs
With the Divi Layout Packs you’ll get world-class designs ready to be used for your client projects.
Vanta.js
A fantastic generator for creating 3D and WebGL background animations for your website.
Animating with the Flip Plugin for GSAP
Ryan Mulligan shares some initial experimentation with the FLIP animation technique provided by the GreenSock Animation Platform for add-to-cart transitions.
Biased by Design
A resource for cultivating awareness of when and how cognitive bias can be introduced into the design process. By Jon Yablonski.
A New Container Query Polyfill That Just Works
Chris Coyier shares an easy-to-use CSS container query polyfill that works.
Announcing Parcel CSS
Read all about @parcel/css, a new CSS parser, compiler, and minifier written in Rust.
Rotating Shapes in Isometric Space
An incredibly interesting thread by Angus Doolan on his insight into the problem of rotating any pixelart shape in any direction in an isometric world.
Color Modulation
Introduce a touch of beautiful, organic color variance to your generative compositions with just a few lines of code. By George Francis.
Dithered Branches – How My Generative Art Works
Frank Force shares how his insight on how he did some experiments with dot matrix printers and glitchy floyd-steinberg dithering.
Three ways to create 3D particle effects
Varun Vachhar shows different ways to create interesting 3D particle effects.
Memory leaks: the forgotten side of web performance
Nolan Lawson writes about why you should, and why shouldn’t care about memory leaks.
Three.js Experiment
A mind-blowing Three.js demo made by Domenico Bruzzese.
How-to: Accessible heading structure
Rian Rietveld explains how to write well-structured headings for reader friendliness and better SEO.
Infinite scrollable and draggable (WebGL) grid
A WebGL powered draggable grid made by Jesper Landberg.
Make Beautiful Gradients in CSS
Josh W Comeau shows how to work around a RGB quirk that causes gradients to look washed out, and create beautiful, lush, saturated gradients instead.
Image Gallery Template
An image gallery template made by Paul Henschel, perfect for exhibiting digital token art.
Responsive Houdini 3D Carousel
Jhey Thomkins made this fantastic demo of a responsive 3D carousel using Houdini, 3D transforms, and custom properties.
Window.js
Window.js is an open-source JavaScript runtime for desktop graphics programming that comes with APIs familiar to web and desktop developers.
How my website works
Brian Lovin gives some insight into how his website works, which is a borderline SaaS-ready web application including user account management, emails, comments, GraphQL, caching, end-to-end tests, and so much more.
Minimator
A minimalist tablet-first graphical editor where all drawings are made of lines in a grid based canvas.
Materialized
A project by Liviu Avasiloiei, where he challenges the way we interact with logos by taking them out of the branding context, transforming them into objects and placing them in unexpected environments.
Your CSS reset needs text-size-adjust (probably)
Kilian Valkhof explains how the -webkit-text-size-adjust
property can help control Mobile Safari’s font-size inflation.
Building a Scrollable and Draggable Timeline with GSAP
Learn how to build a scrollable and draggable horizontal timeline using GSAP’s ScrollTrigger and Draggable plugins.
Crafting Scroll Based Animations in Three.js
Learn how to create a scroll based animation in WebGL in this tutorial from Bruno Simon’s Three.js Journey course.
Pixel Distortion Effect with Three.js
An interactive WebGL pixel distortion effect with lots of possibilities based on the effect seen on the website for “Infinite Bad Guy”.
The post Collective #694 appeared first on Codrops.
Building A Web Code Editor
An online web code editor is most useful when you do not have the opportunity to use a code editor application, or when you want to quickly try out something on the web with your computer or even your mobile phone. This is also an interesting project to work on because having the knowledge of how to build a code editor will give you ideas on how to approach other projects that require you to integrate a code editor to show some functionality.
Here are a few React concepts you’ll need to know in order to follow along in this article:
- Hooks,
- Component structure,
- Functional components,
- Props.
We will be using a library named CodeMirror to build our editor. CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is especially for editing code and comes with a number of language modes and add-ons for more advanced editing functionality.
A rich programming API and a CSS theming system are available for customizing CodeMirror to fit your application and extending it with new functionality. It gives us the functionality to create a rich code editor that runs on the web and shows us the result of our code in real time.
In the next section, we will set up our new React project and install the libraries we need to build our web app.
Creating A New React ProjectLet’s start by creating a new React project. In your commandline interface, navigate to the directory in which you want to create your project, and let’s create a React application and name it code_editor
:
npx create-react-app code_editor
Having created our new React application, let’s navigate to that project’s directory in the commandline interface:
cd code_editor
There are two libraries we need to install here: codemirror
and react-codemirror2
.
npm install codemirror react-codemirror2
Having installed the libraries we need for this project, let’s create our tabs and enable tab switching between the three tabs that will appear in our editor (for HTML, CSS, and JavaScript).
Button Component
Instead of creating individual buttons, let’s make the button a component that is reusable. In our project, the button would have three instances, according to the three tabs we need.
Create a folder named components
in the src
folder. In this new components
folder, create a JSX file named Button.jsx
.
Here is all of the code needed in the Button
component:
import React from 'react'
const Button = ({title, onClick}) => {
return (
<div>
<button
style={{
maxWidth: "140px",
minWidth: "80px",
height: "30px",
marginRight: "5px"
}}
onClick={onClick}
>
{title}
</button>
</div>
)
}
export default Button
Here is a full explanation of what we did above:
- We created a functional component named
Button
, which we then exported. - We destructured
title
andonClick
from the props coming into the component. Here,title
would be a string of text, andonClick
would be a function that gets called when a button is clicked. - Next, we used the
button
element to declare our button, and used thestyle
attributes to style our button to look presentable. - We added the
onClick
attribute and passed our destructuredonClick
function props to it. - The last thing you’ll notice we did in this component is pass in
{title}
as the content of thebutton
tag. This allows us to display the title dynamically, based on what prop is being passed to the instance of the button component when it is called.
Now that we have created a reusable button component, let’s move on and bring our component into App.js.
Go to App.js
and import the newly created button component:
import Button from './components/Button';
To track which tab or editor is open, we need a declare state to hold the value of the editor that is open. Using the useState
React hook, we’ll set up the state that will store the name of the editor tab that is currently open when that tab’s button is clicked.
Here is how we do that:
import React, { useState } from 'react';
import './App.css';
import Button from './components/Button';
function App() {
const [openedEditor, setOpenedEditor] = useState('html');
return (
<div className="App">
</div>
);
}
export default App;
Here, we declared our state. It takes the name of the editor that is currently open. Because the value html
is passed as the state’s default value, the HTML editor would be the tab open by default.
Let’s move on and write the function that will use setOpenedEditor
to change the value of the state when a tab button is clicked.
Note: Two tabs may not be open at the same time, so we’ll have to consider that when writing our function.
Here is what our function, named onTabClick
, looks like:
import React, { useState } from 'react';
import './App.css';
import Button from './components/Button';
function App() {
...
const onTabClick = (editorName) => {
setOpenedEditor(editorName);
};
return (
<div className="App">
</div>
);
}
export default App;
Here, we passed a single function argument, which is the name of the tab currently selected. This argument would be supplied anywhere the function is called, and the relevant name of that tab would be passed in.
Let’s create three instances of our Button
for the three tabs we need:
<div className="App">
<p>Welcome to the editor!</p>
<div className="tab-button-container">
<Button title="HTML" onClick={() => {
onTabClick('html')
}} />
<Button title="CSS" onClick={() => {
onTabClick('css')
}} />
<Button title="JavaScript" onClick={() => {
onTabClick('js')
}} />
</div>
</div>
Here is what we did:
- We started by adding a
p
tag, basically just to give some context to what our application is about. - We used a
div
tag to wrap our tab buttons. Thediv
tag carries aclassName
that we will use to style the buttons into a grid display in the CSS file later in this tutorial. - Next, we declared three instances of the
Button
component. If you recall, theButton
component takes two props,title
andonClick
. In every instance of theButton
component, these two props are provided. - The
title
prop takes the title of the tab. - The
onClick
prop takes a function,onTabClick
, which we just created and which takes a single argument: the name of the tab selected.
Based on the tab currently selected, we would use the JavaScript ternary operator to display the tab conditionally. This means that if the value of the openedEditor
state is set to html
(i.e. setOpenedEditor('html')
), then the tab for the HTML section would become the currently visible tab. You’ll understand this better as we do it below:
...
return (
<div className="App">
...
<div className="editor-container">
{
openedEditor === 'html' ? (
<p>The html editor is open</p>
) : openedEditor === 'css' ? (
<p>The CSS editor is open!!!!!!</p>
) : (
<p>the JavaScript editor is open</p>
)
}
</div>
</div>
);
...
Let’s go over the code above in plain English. If the value of openedEditor
is html
, then display the HTML section. Otherwise, if the value of openedEditor
is css
, then display the CSS section. Otherwise, if the value is neither html
nor css
, then that means the value must be js
, because we have only three possible values for the openedEditor
state; so, then we’d display the tab for JavaScript.
We used paragraph tags (p
) for the different sections in the ternary operator conditions. As we proceed, we will create the editor components and replace the p
tags with the editor components themselves.
We have come so far already! When a button is clicked, it fires up the action that sets the tab it represents to true
, making that tab visible. Here’s what our app currently looks like:
Let’s add a little CSS to the div
container holding the buttons. We want the buttons to be displayed in a grid, instead of stacked vertically like in the image above. Go to your App.css
file and add the following code:
.tab-button-container{
display: flex;
}
Recall that we added className="tab-button-container"
as an attribute in the div
tag holding the three-tab buttons. Here, we styled that container, using CSS to set its display to flex
. This is the result:
Be proud of how much you’ve done to get to this point. In the next section, we will create our editors, replacing the p
tags with them.
Because we have already installed the libraries we are going to be working on within our CodeMirror editor, let’s go ahead and create our Editor.jsx
file in the components
folder.
components > Editor.jsx
Having created our new file, let’s write some initial code in it:
import React, { useState } from 'react';
import 'codemirror/lib/codemirror.css';
import { Controlled as ControlledEditorComponent } from 'react-codemirror2';
const Editor = ({ language, value, setEditorState }) => {
return (
<div className="editor-container">
</div>
)
}
export default Editor
Here's what we did:
- We imported React alongside the
useState
hook because we are going to need it. - We imported the CodeMirror CSS file (which comes from the CodeMirror library that we installed, so you don’t have to install it in any special way).
- We imported
Controlled
fromreact-codemirror2
, renaming it toControlledEditorComponent
to make it clearer. We will be using this shortly. - Then, we declared our
Editor
functional component, and we have a return statement with an emptydiv
, with aclassName
in the return statement for now.
In our functional component, we destructured some values from the props, including language
, value
, and setEditorState
. These three props would be supplied in any instance of the editor when it is called in App.js
.
Let’s use ControlledEditorComponent
to write the code for our editor. Here’s what we’ll do:
import React, { useState } from 'react';
import 'codemirror/lib/codemirror.css';
import 'codemirror/mode/xml/xml';
import 'codemirror/mode/javascript/javascript';
import 'codemirror/mode/css/css';
import { Controlled as ControlledEditorComponent } from 'react-codemirror2';
const Editor = ({ language, value, setEditorState }) => {
return (
<div className="editor-container">
<ControlledEditorComponent
onBeforeChange={handleChange}
value= {value}
className="code-mirror-wrapper"
options={{
lineWrapping: true,
lint: true,
mode: language,
lineNumbers: true,
}}
/>
</div>
)
}
export default Editor
Let’s walk through what we did here, explaining some CodeMirror terms.
The CodeMirror modes specify which language an editor is meant for. We imported three modes because we have three editors for this project:
- XML: This mode is for HTML. It uses the term XML.
- JavaScript: This (
codemirror/mode/javascript/javascript
) brings in JavaScript mode. - CSS: This (
codemirror/mode/css/css
) brings in CSS mode.
Note: Because the editor is built as a component that is reusable, we cannot put a direct mode in the editor. So, we supply the mode through the language
prop that we destructured. But this doesn’t change the fact that the modes need to be imported in order to work.
Next, let’s discuss the things in ControlledEditorComponent
:
onBeforeChange
This is called anytime you write to or remove from the editor. Think of this like theonChange
handler you would normally have in an input field to track changes. Using this, we will be able to get the value of our editor anytime there's a new change and save it to our editor’s state. We will write the{handleChange}
function as we proceed.value = {value}
This is just the content of the editor at any given time. We passed a destructured prop namedvalue
to this attribute. Thevalue
props is the state holding the value of that editor. This would be supplied from the editor’s instance.className
="code-mirror-wrapper"
This class name is not a style we make ourselves. It is supplied from CodeMirror’s CSS file, which we imported above.options
This is an object that takes the different functionality we want our editor to have. There are many amazing options in CodeMirror. Let’s look at the ones we used here:lineWrapping: true
This means that code should wrap to the next line when the line is full.lint: true
This allows linting.mode: language
This mode, as discussed above, takes the language that the editor is going to be used for. The language has already been imported above, but the editor is going to apply a language based on thelanguage
value supplied to the editor via the prop.lineNumbers: true
This specifies that the editor should have line numbers for each line.
Next, we can write the handleChange
function for the onBeforeChange
handler:
const handleChange = (editor, data, value) => {
setEditorState(value);
}
The onBeforeChange
handler gives us access to three things: editor, data, value
.
We only need the value
because it is what we want to pass in our setEditorState
prop. The setEditorState
prop represents the set value for each state that we declared in App.js
, holding the value for each editor. As we move on, we will look at how to pass this as a prop to the Editor
component.
Next, we’ll add a dropdown that allows us to select different themes for the editor. So, let’s look at themes in CodeMirror.
CodeMirror Themes
CodeMirror has multiple themes we can select from. Visit the official website to see demos of the different themes available. Let’s make a dropdown with different themes that the user can choose from in our editor. For this tutorial, we’ll be adding five themes, but you can add as many as you like.
First, let’s import our themes in the Editor.js
component:
import 'codemirror/theme/dracula.css';
import 'codemirror/theme/material.css';
import 'codemirror/theme/mdn-like.css';
import 'codemirror/theme/the-matrix.css';
import 'codemirror/theme/night.css';
Next, create an array of all of the themes we have imported:
const themeArray = ['dracula', 'material', 'mdn-like', 'the-matrix', 'night']
Let’s declare a useState
hook to hold the value of the selected theme, and set the default theme as dracula
:
const [theme, setTheme] = useState("dracula")
Let’s create the dropdown:
...
return (
<div className="editor-container">
<div style={{marginBottom: "10px"}}>
<label for="cars">Choose a theme: </label>
<select name="theme" onChange={(el) => {
setTheme(el.target.value)
}}>
{
themeArray.map( theme => (
<option value={theme}>{theme}</option>
))
}
</select>
</div>
// the rest of the code comes below...
</div>
)
...
In the code above, we used the label
HTML tag to add a label to our dropdown, and then added the select
HTML tag to create our dropdown. The option
tag in the select
element defines the options available in the dropdown.
Because we needed to fill the dropdown with the theme names in the themeArray
that we created, we used the .map
array method to map themeArray
and display the names individually using the option
tag.
Hold on — we’re not done explaining the code above. In the opening select
tag, we passed the onChange
attribute to track and update the theme
state whenever a new value is selected in the dropdown. Whenever a new option is selected in the dropdown, the value is gotten from the object returned to us. Next, we use the setTheme
from our state hook to set the new value to be the value that the state holds.
At this point, we have created our dropdown, set up our theme’s state, and written our function to set the state with the new value. The final thing we need to do to make CodeMirror use our theme is pass the theme to the options
object in ControlledEditorComponent
. In the options
object, let’s add a value named theme
, and set its value to the state’s value for the selected theme, also named theme
.
Here’s what ControlledEditorComponent
would look like now:
<ControlledEditorComponent
onBeforeChange={handleChange}
value= {value}
className="code-mirror-wrapper"
options={{
lineWrapping: true,
lint: true,
mode: language,
lineNumbers: true,
theme: theme,
}}
/>
Now, we have made a dropdown of different themes that can be selected from in the editor.
Here’s what the full code in Editor.js
looks like at the moment:
import React, { useState } from 'react';
import 'codemirror/lib/codemirror.css';
import 'codemirror/theme/dracula.css';
import 'codemirror/theme/material.css';
import 'codemirror/theme/mdn-like.css';
import 'codemirror/theme/the-matrix.css';
import 'codemirror/theme/night.css';
import 'codemirror/mode/xml/xml';
import 'codemirror/mode/javascript/javascript';
import 'codemirror/mode/css/css';
import { Controlled as ControlledEditorComponent } from 'react-codemirror2';
const Editor = ({ language, value, setEditorState }) => {
const [theme, setTheme] = useState("dracula")
const handleChange = (editor, data, value) => {
setEditorState(value);
}
const themeArray = ['dracula', 'material', 'mdn-like', 'the-matrix', 'night']
return (
<div className="editor-container">
<div style={{marginBottom: "10px"}}>
<label for="themes">Choose a theme: </label>
<select name="theme" onChange={(el) => {
setTheme(el.target.value)
}}>
{
themeArray.map( theme => (
<option value={theme}>{theme}</option>
))
}
</select>
</div>
<ControlledEditorComponent
onBeforeChange={handleChange}
value= {value}
className="code-mirror-wrapper"
options={{
lineWrapping: true,
lint: true,
mode: language,
lineNumbers: true,
theme: theme,
}}
/>
</div>
)
}
export default Editor
There’s only one className
that we need to style. Go to App.css
and add the following style:
.editor-container{
padding-top: 0.4%;
}
Now that our editors are ready, let’s go back to App.js
and use them there.
src > App.js
The first thing we need to do is import the Editor.js
component in here:
import Editor from './components/Editor';
In App.js
, let’s declare the states that will hold the contents of the HTML, CSS, and JavaScript editors, respectively.
const [html, setHtml] = useState('');
const [css, setCss] = useState('');
const [js, setJs] = useState('');
If you recall, we will need to use these states to hold and supply the contents of our editors.
Next, let’s replace the paragraph (p
) tags that we used for the HTML, CSS, and JavaScript in the conditional renderings with the editor components we have just created, and we’ll also pass in the appropriate prop to each instance of the editor component:
function App() {
...
return (
<div className="App">
<p>Welcome to the edior</p>
// This is where the tab buttons container is...
<div className="editor-container">
{
htmlEditorIsOpen ? (
<Editor
language="xml"
value={html}
setEditorState={setHtml}
/>
) : cssEditorIsOpen ? (
<Editor
language="css"
value={css}
setEditorState={setCss}
/>
) : (
<Editor
language="javascript"
value={js}
setEditorState={setJs}
/>
)
}
</div>
</div>
);
}
export default App;
If you’ve been following along until now, you’ll understand what we did in the code block above.
Here it is in plain English: We replaced the p
tags (which were there as placeholders) with instances of the editor components. Then, we supplied their language
, value
, and setEditorState
props, respectively, to match their corresponding states.
We've come so far! Here is what our app looks like now:
(Large preview) Introduction to IframesWe’ll be making use of inline frames (iframes) to display the result of the code entered in the editor.
According to MDN:
The HTML Inline Frame element (
<iframe>
) represents a nested browsing context, embedding another HTML page into the current one.
How Iframes Work in React
Iframes are normally used with plain HTML. Using Iframes with React doesn’t require many changes, the major one being to convert attribute names to camelcase. An example of this is that srcdoc
would become srcDoc
.
The Future of Iframes on the Web
Iframes continue to be really useful in web development. Something you might want to check out is Portals. As Daniel Brain explains:
“Portals introduce a powerful new set of capabilities into this mix. Now it’s possible to build something that feels like an iframe, that can seamlessly animate and morph and take over the full browser window.”
One of the things Portals tries to solve is the URL bar problem. When using iframe, components rendered in the iframe don’t carry a unique URL in the address bar; as such, this might not be great for the user experience, depending on the use case. Portals is worth checking out, and I’d suggest you do that, but because it is not the focus of our article, this is all I’ll say about it here.
Creating the Iframe to House Our ResultLet’s move ahead with our tutorial by creating an iframe to house the result of our editors.
return (
<div className="App">
// ...
<div>
<iframe
srcDoc={srcDoc}
title="output"
sandbox="allow-scripts"
frameBorder="1"
width="100%"
height="100%"
/>
</div>
</div>
);
Here, we created the iframe and housed it in a div
container tag. In the iframe, we passed some attributes that we need:
srcDoc
ThesrcDoc
attribute is written in camelcase because this is how to write iframe attributes in React. When using an iframe, we can either embed an external web page on the page or render specified HTML content. To load and embed an external page, we would use thesrc
property instead. In our case, we are not loading an external page; rather, we want to create a new internal HTML document that houses our result; for this, we need thesrcDoc
attribute. This attribute takes the HTML document that we want to embed (we have not created that yet, but we will soon).title
The title attribute is used to describe the contents of the inline frame.sandbox
This property has many purposes. In our case, we are using it to allow scripts to run in our iframe with theallow-scripts
value. Because we are working with a JavaScript editor, this would come in handy quickly.frameBorder
This merely defines the border thickness of the iframe.width
andheight
This defines the width and height of the iframe.
These terms should now make more sense to you. Let’s move on and declare the state that will hold the HTML template document for srcDoc
. If you look closely at the code block above, you’ll see that we passed a value to the srcDoc
attribute: srcDoc
={srcDoc}
. Let’s use our useState()
React hook to declare the srcDoc
state. To do this, in the App.js
file, go to where we defined the other states and add this one:
const [srcDoc, setSrcDoc] = useState(` `);
Now that we have created the state, the next thing to do is display the result in the state whenever we type in the code editor. But what we don’t want is to re-render the component on every single key press. With that in mind, let’s proceed.
Configuring the Iframe to Display the Result
Every time there's a change in any of the editors for the HTML, CSS, and JavaScript, respectively, we want useEffect()
to be triggered, and that will render the updated result in the iframe. Let’s write useEffect()
to do this in the App.js
file:
First, import the useEffect()
hook:
import React, { useState, useEffect } from 'react';
Let’s write useEffect()
like so:
useEffect(() => {
const timeOut = setTimeout(() => {
setSrcDoc(
`
<html>
<body>${html}</body>
<style>${css}</style>
<script>${js}</script>
</html>
`
)
}, 250);
return () => clearTimeout(timeOut)
}, [html, css, js])
Here, we wrote a useEffect()
hook that will always run whenever the value states that we declared for the HTML, CSS, and JavaScript editors are changed or updated.
Why did we need to use setTimeout()
? Well, if we wrote this without it, then every time a single key press is made in an editor, our iframe would be updated, and that isn’t great for performance generally. So we use setTimeout()
to delay the update for 250 milliseconds, giving us enough time to know whether the user is still typing. That is, every time the user presses a key, it restarts the count, so the iframe would only be updated when the user has been idle (not typing) for 250 milliseconds. This is a cool way to avoid having to update the iframe every time a key is pressed.
The next thing we did above was to update srcDoc
with the new changes. The srcDoc
component, as we explained above, renders specified HTML content in the iframe. In our code, we passed an HTML template, taking the html
state that contains the code that the user has typed into the HTML editor and placing it between the body
tags of our template. We also took the css
state that contains the styles that the user has typed in the CSS editor, and we passed that between the style
tags. Finally, we took the js
state that contains the JavaScript code that the user has typed in the JavaScript editor, and we passed it between the script
tags.
Notice that in setting setSrcDoc
, we used backticks (` `
) instead of normal quotes (' '
). This is because backticks allow us to pass in corresponding state values, as we did in the code above.
The return
statement in the useEffect()
hook is a cleanup function that clears setTimeout()
when it is complete, to avoid memory leakage. The documentation has more about useEffect
.
Here’s what our project looks like at the moment:
(Large preview)CodeMirror Addons
With CodeMirror addons, we can enhance our editor with more of the kind of functionality we would find in other code editors. Let’s walk through an example of closing tags being added automatically when an opening tag is typed, and another example of a bracket automatically closing when the opening bracket is inputted:
The first thing to do is import the addon for this into our App.js
file:
import 'codemirror/addon/edit/closetag';
import 'codemirror/addon/edit/closebrackets';
Let’s pass it in the ControlledEditorComponent
options:
<ControlledEditorComponent
...
options={{
...
autoCloseTags: true,
autoCloseBrackets: true,
}}
/>
Now here’s what we have:
(Large preview)You could add a ton of these addons to your editor to give it richer features. We couldn’t possibly go through all of them here.
Now that we are done with this, let’s briefly discuss things we could do to improve our app’s accessibility and performance.
Performance and Accessibility of the SolutionLooking at our web code editor, some things could definitely be improved upon.
Because we’ve paid attention primarily to functionality, we might have neglected design a little bit. For better accessibility, here are some things you could do to improve this solution:
- You could set an
active
class on the button for the currently open editor. Highlighting the button would improve accessibility by giving users a clear indication of which editor they’re currently working on. - You might want the editor to occupy more screen space than what we have here. Another thing you could try is making the iframe pop up with the click of a button that is docked somewhere to the side. Doing so would give the editor more screen space.
- This sort of editor would be useful for people who want to run a quick exercise on their mobile device, so fully adapting it to mobile would be necessary (not to mention both of the points about mobile above).
- Currently, we are able to switch the theme of the editor component from among the multiple themes we’ve loaded in, but the general theme of the page remains the same. You could enable the user to switch between a dark and light theme for the entire layout. This would be good for accessibility, relieving the strain on people’s eyes from looking at a bright screen for too long.
- We didn’t look at security issues with our iframe, mainly because we were loading an internal HTML document in the iframe, rather than an external document. So we don’t need to consider this too carefully because iframes are a good fit for our use case.
- With iframes, another consideration would be page-loading time, because the content being loaded in the iframe would normally be out of your control. In our app, this isn’t an issue because our iframe content isn’t external.
Performance and accessibility are worth a lot of consideration when you’re building any application because they will determine how useful and usable your application is to its users.
Shedrack has done a good job of explaining methods for improving and optimizing performance in React apps. It’s worth checking out!
ConclusionWorking through different projects helps us to learn about a wide range of subjects. Now that you’ve gone through this article, feel free to expand upon your experience by experimenting with more add-ons to make the code editor richer, revamping the UI, and fixing the accessibility and performance concerns outlined above.
- The entire code base for this project is available on GitHub.
Here’s the demo on Codesandbox:
Links and Material
- “Google Chrome’s Portals: Like Iframes, But Better, and Worse”, Daniel Brain
- “Optimizing Performance”, React documentation
- “User Manual and Reference Guide”, CodeMirror documentation
how to write in excel file of sql query result
i have below stuff an i write each result in excel sheet . i have an issue to write in excel sheet of each sql result
drop table #table_Northwind
create table #table_Northwind
(
RowID int not null identity(1,1) primary key,
column_name varchar(50)
)
insert into #table_Northwind (column_name)
(SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
where TABLE_TYPE = 'BASE TABLE' AND TABLE_CATALOG='Northwind' )
--select * from #table_Northwind
declare @tbl_name nvarchar(50)
declare @i int
select @i = min(RowID) from #table_Northwind
declare @max int
select @max = max(RowID) from #table_Northwind
while @i <= @max begin
SELECT (select column_name from #table_Northwind where RowID=@i) 'TableName' , o.name, [Scehma]=schema_name(o.schema_id), o.type
FROM sys.sql_modules m
INNER JOIN sys.objects o
ON o.object_id = m.object_id
WHERE m.definition like +'%'+ (select column_name from #table_Northwind where RowID=@i) +'%'
set @i = @i + 1
end
Application Cloud Migration or Application Modernization?
Traditional software applications and on-premise legacy applications have limited computing power. However, innovations and trials require enormous computing resources. As a result, enterprises are looking at cloud migration and application modernization as the preliminary business requirement for launching innovations. It not only allows them to execute cross geography trials but also test digital innovations with AI/ML algorithms that require exhaustive computing.
Application Cloud Migration and Application Modernization Are Synonymous
Application cloud migration entails the movement of the on-premise applications to the cloud environment, either on-premise cloud or public cloud, in order to avail the benefits of scalability, flexibility, and exponential computing power. It is synonymous with application modernization that allows the erstwhile on-premise application in its cloud-borne avatar to process queries and data at a tremendous speed. The applications are on the same turf as the cloud-first applications that are the true proponents of the cloud-native environment.
How to Do Lead Generation in WordPress Like a Pro
Do you want to generate leads and increase sales from your website?
Lead generation should be a top priority for all businesses because converting visitors into subscribers and customers is how you make money online.
In this article, we’ll show you how to do lead generation in WordPress like a pro.
This is a comprehensive guide on lead generation in WordPress, so we’ve added a table of contents for easier navigation:
- What is lead generation?
- Getting started with lead generation in WordPress
- Lead generation using forms in WordPress
- Lead generation using popups and dynamic opt ins
- Lead generation using custom WordPress pages
- Lead generation using online calculators
- Lead generation using viral giveaways
- Lead generation improving WordPress comments
- Optimizing your WordPress lead generation campaigns
What is Lead Generation in WordPress?
Lead generation means getting potential customers, or ‘leads’, interested in your products and services, and capturing their contact information.
More than 75% of visitors that come to your website will leave, and you’ll never hear from them again. But by having strong lead generation in place, you can gather those users’ information and continue to engage with them, and turn them into happy customers.
Depending on the type of website you run, you can encourage your visitors to share their contact information by:
- Submitting a contact or inquiry form on your site
- Joining your email newsletter
- Signing up for an upcoming webinar
- Using an online calculator with email results
- Entering a viral giveaway you run
Essentially, lead generation is all about opening a communication channel between you and your visitors.
Once you get a user to perform an action that opens up a communication channel, you can begin to send them special offers, freebies, good content, and more to bring them back to your website and convert them into customers.
Who Should Start Generating Leads?
Whether you’re a new blogger, a small or large business, or even a hobby blogger, you need to start doing lead generation.
Even non-profit owners can benefit from lead generation to get more support and donations.
If you care about growing your audience and getting more traffic to your website, then you should start generating leads today.
Many successful online marketers and bloggers will tell you that the biggest mistake was not starting an email list to capture leads earlier.
When Should I Start Lead Generation?
It takes time to generate leads. Every moment you don’t have lead generation in place, you lose potential customers.
Even when you just started a blog and are only getting a little bit of traffic, those leads can build over time.
Business owners who haven’t launched their websites yet can still benefit from lead generation by creating coming soon pages to create anticipation and hype before launch.
With that said, let’s take a look at how to get started with lead generation in WordPress.
Getting Started with Lead Generation in WordPress
Before you can start generating leads, you must make sure that you are using the right WordPress platform. Yes, there are two types of WordPress.
We recommend using WordPress.org, the self hosted version, because it lets you use all WordPress features without any restrictions and build a website ready to generate leads.
For more details, see our comparison between WordPress.com vs WordPress.org.
You’ll need the following things to get started building a WordPress site for lead generation:
- WordPress hosting (this is where your website files are stored)
- A domain name (for example, wpbeginner.com)
- WordPress lead generation tools and plugins (highlighted below)
First you need to get a domain name and web hosting.
We recommend using Bluehost for your web hosting. Their hosting plans are officially recommended by WordPress.
WPBeginner readers can currently get a big 60% discount on hosting, plus a free domain name and SSL certificate.
Simply click on the Bluehost button below, and the discount will automatically be applied.
Once you’ve purchased hosting, make sure to check out our ultimate guide on how to make a website.
Recommended Lead Generation Tools and Plugins to Get Started
Next, there are a few plugins and tools we highly recommend using for lead generation.
First, you need to sign up with a email marketing service provider. This will let you collect email addresses on your website to build your email list and send emails in an easy to use interface.
Some great services to get started with include Constant Contact, HubSpot, and Sendinblue.
Next, you’ll also need a popup tool like OptinMonster. It’s one of the best popup plugins and lead generation tools in the market used by over 1.2 million websites.
This will help you create popups, floating bars, scroll boxes, and more to collect leads on your website.
You’ll also want a WordPress form builder like WPForms. It’s one of the best lead generation plugins and form builders in the market used by over 5 million sites.
This will help you create lead generation forms, sign up forms, and more.
Aside from that, we’ll be covering several other WordPress lead generation plugins, tools, and tips below to help you convert website visitors into leads, customers, and subscribers.
Lead Generation Using Forms in WordPress
One of the most effective ways to generate leads on your website is using WordPress forms. This can be a simple contact form, request a quote form, general interest form, and much more.
The easiest way to add forms to your website is by using the WPForms plugin mentioned above.
It’s very beginner friendly and will let you create nearly any kind of form with the drag and drop builder. There are over 300+ form templates you can use to get started.
Plus, it integrates will all the top email marketing providers, so you can easily send your leads to your preferred tool.
Below we’ll show you a few different ways you can use WPForms to generate leads.
Create Simple Lead Generation Forms in WordPress
The simplest way to generate leads on your site is with a simple contact form. WPForms makes it easy to create a contact form in minutes using the drag and drop builder.
You can even use the free version of WPForms to create a simple form and connect it to Constant Contact for sending emails to your list.
For more details, see our step by step guide on how to create a contact form in WordPress.
WPForms also has built in settings that let you view and manage all of your form submissions directly from your WordPress dashboard.
Simply go to WPForms » Entries, and you can view all of your form submissions.
Redirect Users After Form Submission
Another technique you can use to boost sales and sign ups is adding a redirect page upon successful form submission.
WPForms allows you to easily redirect users to any page after submitting a form using the smart form confirmation feature.
To do this, go to Settings » Confirmations in your form editor screen and then select your confirmation type from the drop down list.
You can choose to show a confirmation message, redirect users to another WordPress page, or even a different URL.
If you select the ‘Show Page’ option, then you can create a separate page on your WordPress site with special offers, coupons, or show users content to help convert visitors into customers.
Once you’re done, make sure to click the ‘Save’ button to confirm your changes.
Add Newsletter Signup Forms to Your Website
Contact forms and other types of inquiry forms are great for collecting inbound leads, but you can also use them to build your email list.
Using WPForms, you can create simple email newsletter opt in forms to add to different areas of your website.
To set up your email newsletter form, see our guide on how to create an email newsletter the right way.
You can add these forms to different areas of your WordPress site, including your sidebar, footer area, and below your blog posts.
If you want to create simple single line forms that are easy to place throughout your site, then see our guide on how to display your form in a single line in WordPress.
Lead Generation Using Popups and Dynamic Opt ins in WordPress
When doing lead generation, it’s important to have multiple types of lead generation in place. For example, your readers might miss a simple sidebar email opt in box, but you can create engaging popups that will capture your reader’s attention.
This is where OptinMonster comes in. It’s the best email capture tool for WordPress that allows you to create high-converting opt in forms for your WordPress site without hiring a developer.
We use it on WPBeginner and have increased our conversions by over 600% with this plugin alone.
With OptinMonster, you can create personalized opt ins based on user behavior, so you can send users the right message at the right time.
For example, you can create customized opt ins that will show up based on:
- The page, post, or category being viewed
- Your user’s location in the world
- What previous interactions they’ve taken on your site
- Where your visitors are coming from (Google Search, Facebook, etc.)
- Which device they’re using to browse your site
- And much more
Combined with these targeting options, dynamic opt in forms are the most powerful tool in any marketer’s toolbox.
Here are a few different ways you can use OptinMonster to generate more leads.
Use Exit-Intent Lightbox Popup for Email Signups
OptinMonster has a unique exit-intent technology that detects when a user’s mouse is leaving the page and shows a popup at that exact moment.
This gives your visitors one last chance to sign up before they decide to leave your website. It’s less intrusive and doesn’t annoy your visitors since it won’t show up until they’re leaving.
Exit intent popups simply work, which is why we use them on all of our brands for easy lead generation.
With OptinMonster, there’s also a wide variety of popup types you can create like spin to win opt ins, floating bars, mobile popups, and more.
You can create multiple different types of opt ins for your site and test them to see what works best.
Now, we’ll look at a few more unique ways to use OptinMonster for lead generation.
Boost Conversions with Fullscreen Welcome Mats
Welcome mats let you capture your visitor’s attention and allow you to display a full screen overlay on your content.
To view the page, your visitors will need to give you their contact information or close it.
Similar to exit intent popups, this style of opt in also converts incredibly well.
For more details, see our guide on how to create a welcome mat for your WordPress site.
Lock Your Content to Improve Lead Generation
Content locking is a technique used by site owners to encourage people to take action.
This can be anything from joining an email newsletter to signing up for a premium paywall.
If you have a ton of high-quality content, then you can hide this behind a content locker to generate more leads.
For more details, see our guide on how to add content locking to WordPress.
Offer Users Incentives to Join Your Email List
Similar to using a content locker, a content upgrade is an exclusive bonus you offer to your readers in exchange for joining your email list.
You can create all kinds of content upgrades like checklists, eBooks, worksheets, and more.
Content upgrades are great because they use on-click popups to deliver the download. Your visitors simply click the link and a popup will appear.
This takes advantage of the powerful Zeigarnik effect. This psychological principle states that users who start an action are more likely to finish it.
For more details, see our guide on how to add content upgrades in WordPress and grow your email list.
Lead Generation Using Custom WordPress Pages
When building your site, you may need to create custom pages to generate leads. For example, you can create a landing page that people will visit when coming to your site from social media only.
These pages are built for a very specific purpose and often have higher conversion rates than other pages since there’s less distraction.
The easiest way to build these custom pages is by using SeedProd. It’s the best drag and drop WordPress page builder in the market used by over 1 million websites.
With this plugin, you can create any type of landing page without writing any code. It has dozens of professional templates you can customize easily with the drag and drop builder.
Many of these can be used to generate leads, like opt in pages, sales funnel landing pages, webinar registration pages, and more.
You can also connect SeedProd with popular email marketing tools and other lead generation plugins like WPForms.
Every single template can be completely customized to help you start generating leads as quickly as possible.
There are dozens of blocks designed to improve your landing pages and convert better, like countdown timers, CTA buttons, rotating testimonials, and more.
For more details on building high converting landing pages, see our guide on how to create a landing page in WordPress.
Lead Generation in WordPress Using Simple Online Calculators
Online calculators are a very popular type of lead magnet used by some of the best blogs in the world today.
These calculators help your users solve a problem or answer a question. To get the results from the calculator, your readers will enter their email addresses.
You can use online calculators in virtually any popular blogging niche like finance, fitness, travel, and much more.
The easiest way to add online calculators to your website is by using the Formidable Forms plugin. It’s the best WordPress calculator plugin in the market and makes it easy to build advanced online calculators without writing code.
It integrates with popular email marketing providers and small business CRMs, so you can send your new leads directly to your provider of choice.
Plus, it comes with dozens of different templates like BMI calculators, paycheck calculators, mortgage calculators, and more you can use to create new calculators quickly.
For more details, see our guide on how to generate more leads with free online calculators.
Lead Generation in WordPress Using Viral Giveaways
Giveaways are a super powerful way to get more traffic, grow your email list, grow your brand recognition, and more.
Running a giveaway on your WordPress website gives you control over the end result. You can choose whether you want to get more email subscribers, social media followers, and more.
To enter the contest, your users will need to complete an action that you decide.
The easiest way to do this is with RafflePress. It’s the best WordPress giveaway and contest plugin in the market that lets you easily run giveaways on your site.
It has built-in 1-click fraud protection and verification so you can ensure that all of the leads you’re collecting are real.
You can use the viral template library and drag and drop content builder to quickly create your giveaways and contests.
For more details, see our guide on how to run a giveaway / contest in WordPress with RafflePress.
Lead Generation in WordPress by Improving Comments
Comments are a great to build user engagement. If you have users who are regularly commenting and interacting on your site, then there’s a good chance they’ll become a customer or join your email list.
However, the default WordPress comment system is not very efficient in bringing back the users who leave comments.
Here are a few different ways to capture leads from your comment forms and get people to come back to your website.
Capture Leads by Adding a Comment Redirect
By default, when a user submits a comment on your website, they’ll see the same page again. There’s nothing new on that page except for the preview of their new comment.
You can convert these visitors into subscribers by redirecting them to a different page on your site after commenting. This could be a thank you page, a special offer page, and more.
The easiest way to add a comment redirect feature is using the Yoast Comment Hacks plugin.
First thing you need to do is install and activate the plugin. For more details, see our guide on how to install a WordPress plugin.
Upon activation, you need to visit Settings » Comment Hacks page and scroll down to the ‘Redirect first time commenters’ section.
Then, select the page to redirect new commentors from the ‘Redirect to’ drop down list.
After that, click the ‘Save Changes’ button at the bottom of the screen.
Now, all first time commenters on your website will be redirected to your selected page. You can optimize this page by adding an email signup form, offering a special discount, or anything else you want.
Add Comment Subscription Option in WordPress
As we mentioned earlier, WordPress doesn’t send any notifications to users after they leave a comment. The user will have to come back to your site manually to see if someone replied to their comment.
Adding a comment subscription option will allow users to get notified about new comments. This will give you more opportunities to convert those visitors into subscribers.
To do this, we’ll be using the Subscribe to Comments Reloaded plugin. It lets you enable comment subscribers, manage comment subscribers, and more.
You can add a simple checkbox to your comment forms that readers can check to subscribe to comments.
For more details, see our guide on how to allow your users to subscribe to comments in WordPress.
Optimizing Your WordPress Lead Generation Campaigns
Lead generation is an ongoing effort. You will need to monitor what is working well for your website and see how you can improve it.
Here are a few tips that will help you optimize your lead generation efforts over time:
- Track your form conversions to reduce abandonment
- Use an A/B testing tool like Google Optimize to improve opt ins
- Use multiple opt in locations to maximize your efforts
- Experiment with different colors, images, videos, and more
- Create and use multiple lead magnets in different areas of your website
- Think about the user experience and don’t annoy users with too many distractions
Beyond lead generation, you may also want to think about what happens after a visitor becomes a lead.
You’ll need to have an effective follow up strategy and consider your long term sources of leads.
Here are a few ideas to get you started:
- Use a professional business phone service for phone leads
- Use a live chat service or an AI chatbot platform to collect leads and boost conversions
- Use a push notification software as an alternative platform to communicate with website visitors
- Add a CRM to WordPress to better track and follow up with leads
- Optimize your WordPress SEO for long term search engine traffic
- Setup WordPress conversion tracking to see how visitors use your site
We hope this article helped you learn how to do lead generation in WordPress like a pro. You may also want to check out our free business name generator and our expert picks of the best HR payroll software for businesses.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
The post How to Do Lead Generation in WordPress Like a Pro first appeared on WPBeginner.
Biggest Threats Application Development Companies Are Facing Today
Application development is a delicate process. To build high-quality applications, not only expertise is required, but also important measures and their proper implementation. Today, as the number of applications is increasing, problems apart from cyberthreats are increasing in parallel. These threats might cause applications to malfunction, slow them down, or just might make them vulnerable to cyber-attacks. However, there are precautions as well. Blockchain, for instance, is one of the safest servers that application development companies are preferring today.
In this blog, we are discussing some crucial threats and hurdles for app development companies and precautions these companies are taking to avoid them. If you are a tech enthusiast, developer, or app development professional, stick with us until the end to have some amazing insights.