Skip to content

Instantly share code, notes, and snippets.

View jittarao's full-sized avatar

Raghavender Rao Jitta jittarao

View GitHub Profile
<!-- hide Messenger by default -->
<script>
document.addEventListener('gistReady', function () {
gist.chat('hide');
});
</script>
<!-- simply add 'class="gist-open-chat"' to any link on your site -->
<a href="#" class="gist-open-chat">Click me</a>
@jittarao
jittarao / identify.erb
Created October 6, 2022 03:33
Example of an identify call in Rails app
<script>
gist.identify("<%= current_user.id %>", {
"name": "<%= current_user.name %>", // Full name
"email": "<%= current_user.email %>", // Email address
"created_at": "<%= current_user.created_at.to_i %>" // Signup date as a Unix timestamp
});
</script>
@jittarao
jittarao / Embed Chat Into Any Webpage.html
Last active August 18, 2022 05:47
Create a HTML file and paste this code into it. Then embed the page into any other page via an iFrame
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="https://getgist.com/wp-content/themes/convertfox/assets/favicon/favicon.ico">
<title>Gist Chat</title>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/url-polyfill@1.1.12/url-polyfill.min.js"></script>
<script type="text/javascript">
var workspace_id = new URL(window.location.href).searchParams.get("key");
<?php
$user = wp_get_current_user();
if ( in_array( 'ROLE_NAME', (array) $user->roles ) ) {
?>
<script>
document.addEventListener('gistReady', function () {
gist.chat('hide');
});
</script>
<?php } ?>
@jittarao
jittarao / Show Messenger on specific pages on mobile.js
Last active December 7, 2021 19:10
Show Messenger on specific pages on mobile
// PASTE THIS AFTER GIST TRACKING CODE
function isMobile() {
// credit to Timothy Huang for this regex test:
// https://dev.to/timhuang/a-simple-way-to-detect-if-browser-is-on-a-mobile-device-with-javascript-44j3
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
}
document.addEventListener('gistReady', function () {
gist.chat('hide');
@jittarao
jittarao / Callback Events for Gist Messenger.html
Created June 18, 2021 01:18
Send Gist events to an outside platform or customize Gist using specific actions done by your customers.
<!-- Make sure you add Gist snippet above this -->
<!-- This example shows listening to a variety of Gist client side events and logging their contents whenever they happen. -->
<script type="text/javascript">
document.addEventListener("gistChatReady", function(e) {
// Triggers when a new conversation has started
document.addEventListener('conversation:started', function (data) {
console.log('Conversation Started: ' + JSON.stringify(data.detail));
}, false);
// Triggers when a conversation has been opened
<html>
<head>
<!-- Make sure jQuery is added to your website -->
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<style>
/* Hide Messenger bubble using CSS */
.gist-messenger-bubble-iframe {
display: none!important;
}
<style>
@media only screen and (max-width: 480px) {
.gist-messenger-bubble-iframe iframe, .gist-notification-iframe iframe, .gist-post-small-iframe iframe, .gist-prompt-iframe iframe {
bottom: 80px!important; // Change the 80px to move the Messenger vertically from bottom edge fo the screen
right: 40px!important; // Change the 40px to move the Messenger horizontally from right edge fo the screen
// left: 40px!important; // Change the 40px to move the Messenger horizontally from left edge fo the screen
}
}
</style>
<script>
jQuery(".elementor-button").click(function() {
var gist_email = jQuery(this).closest("form").find("input[type=email]").val();
gist.identify(gist_email);
});
</script>
{% if contact.first_name != blank %}Hi {{ contact.first_name | capitalize }}, welcome back! 👋{% else %}Hi there! 👋{% endif %}