---
# System prepended metadata

title: Use Case Scenarios

---

# Use Case Scenarios
This section details some common scenarios for using the Rake Live Chat JS APIs.


---

### Setting visibily of the Live Chat Widget on the page
The Rake Live Chat widget does not have to be visible all the times.  For exaple, on some cirtical pages (e.g. payment page) in your checkout flow, you might prefer to hide the widget.  Or, maybe you prefer to hide the widget after businesss hours or when no agents are available. 

If this is the case, you can set the widget's display on page load, setting widget as hidden and calling JS API methods with conditions.

**Hide widget when no agents available**
```
Script example of widget(hide)/(show) with agents available AND business hours conditions
```

**Hide widget after business hours**
```
Script example of widget(hide)/(show) with business hours only conditions
```

**Hide widget always**
```
Example of widget(hide) script with NO conditions
```



---

### Adding a button or link to open/maximize the live chat widget
Rake Live Chat and the JS API allows configuring any button or link on your webpages to open (maximize) the chat widget on those sites, even if the chat widget was hidden on the original page load. 

You can use on-page buttons and links to engage more visitors into conversations that are contextual to the section they are viewing or reading.  Consider button labels like "Learn More", or "Let's Chat". 

By calling the JS API from Rake Live Chat on-click, this button will open the widget and start a session with the visitor and your workspace. You can also add an introductory message to the visitor to get them started, such as “Hi, I’m looks like you are interested in this {{subject}}. How can we help?”

```
Please provide JS API examples for:

maximize widget

start session

add message

```
```
Please create a jsFiddle or similar full code example and insert the link here.
```



---

### Track chat events in Google Analytics
With Rake Live Chat's JS API, you can track chat releated events that occur during a visitor's web session. For example, using Google Analytics event tracking and the Rake Live Chat JS API, you could understand and report on important events that relate to conversions.  Such as if a chat session occured in the same web session as an online purchase or other “conversion” event you are interested in, whatever that may be.

To track events in Google Analytics, follow these steps:

1. **Reference a valid Google Analytics account** 
You will need the **UA-XXX-Y** value from your Google Analytics account.  This must be present on the site or the page along with the Rake Live Chat widget script. 
```
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->


```

2. **Create or reference your Google Analytics Goals** 
Create new or use existing Goals and associate them with events you'll be tracking from Rake Live Chat. 

Some examples of Chat based conversion goals are 
- "First Time Visitor Chat Started"
- "Returning Visitor Chat Started"
- "Chat Invite Accepted"
- "Chat Invite Declined"

To learn more about how to setup or edit goals in Google Analytics, see https://support.google.com/analytics/topic/6150889

3. **Activate the events you want to report**
``` 
FROM LIVE CHAT INC:
Events are being passed with Category, Action and Label attribute – each corresponding to different information. This integration can collect the following information:

Automated greeting - every time a visitor is sent a greeting.
Rich greeting button clicked - when a visitor clicks a rich greeting button.
Pre-chat survey filled in - when the pre-chat form is submitted.
Chat - when the chat starts.
Ticket form filled in - when the ticket form is submitted.
Post-chat survey filled in - when the post-chat survey is submitted.
```



---

### Form submission button
Many websites offer forms to capture lead data on visitors, but what if after submittin gthe form the lead could start a live chat?  You can  they'll need to do two more things before they can be registered as a lead: fill out a form and click on a button to submit their information to your contacts database. For that purpose, set a "Chat with an expert now" form submission button that will only activate chat session after all data is submitted.