
Customer support is improved significantly with the Shopify Login as Customer App since you can assist customers in placing orders and fixing account-related issues timely. But that's not it.
Shopify store admin is not the only place where you can log in to your customers' accounts from. You can also log in to customer accounts from your CRM or helpdesk, etc. (if they allow you to extend them and run requests to custom API that comes with our app).
But even this is not the only thing custom API allows you to do.
Today we'll consider different scenarios.
Log in to Customer Accounts
You can log in to customer accounts using API in 2 different ways.
Note: the following code is written in PHP, but you can use any other programming language.
Log in As a Customer using the Customer ID
<?php
$publicKey = '****************';
$secretKey = '***********************************';
$shop = '**********'; // for example 'myshop.myshopify.com';
$customer = '**********'; //for example 123456789;
?>
<?php
$currentDate = date('Y-m-d');
$token = hash('sha256', $publicKey . $secretKey . $currentDate . $secretKey . $customer . $publicKey);
$url = 'https://lac.sfapp.magefan.top/api/login?public_key=' . $publicKey . '&customer_id=' . $customer . '&shop=' . $shop;
/* Uncomment next line in case the multi-pass feature is not available for your Shopify account, it will reset the user password and perform login. */
// $url .= '&change_pwd_flag=1';
?>
<form action="<?= $url ?>" method="POST">
<input type="hidden" name="token" value="<?= $token ?>">
<input type="submit" value="Login As Customer: ID <?= $customer ?>">
</form>
Log in As a Customer using the Customer Email
<?php
$publicKey = '****************';
$secretKey = '***********************************';
$shop = '**********'; // for example 'myshop.myshopify.com';
$customer = '**********'; //for example 'jon.doe@domain.com';
?>
<?php
$currentDate = date('Y-m-d');
$token = hash('sha256', $publicKey . $secretKey . $currentDate . $secretKey . $customer . $publicKey);
$url = 'https://lac.sfapp.magefan.top/api/login?public_key=' . $publicKey . '&email=' . $customer . '&shop=' . $shop;
/* Uncomment next line in case the multi-pass feature is not available for your Shopify account, it will reset the user password and perform login. */
// $url .= '&change_pwd_flag=1';
?>
<form action="<?= $url ?>" method="POST">
<input type="hidden" name="token" value="<?= $token ?>">
<input type="submit" value="Login As Customer Email: <?= $customer ?>">
</form>
Here you'll find the $publicKey and $secretKey values which you have to substitute with unique values from your store. For that read the following article about how to get public and secret keys for login as customer API.
Values of the variable $shop should be replaced with your shop domain name, and $customer variable value should be replaced with your customer ID or email.
Track Admins Who Logged Into Customer Accounts
Note: this feature is available only for the Shopify Plus users.
If you want to see who from your admins logged into certain customer accounts, you can do that through our IP. It will allow you to see the admin and login time directly on the customer editing page.
Let's see what you need to do to achieve that.
1. Create a custom app
Go to Settings > Apps and sales channels and hit the Develop apps button at the top right corner. Then click on Create app and start filling out the app details: Name and Developer.
Click Create app once you finish and navigate to the API credentials tab.
Once there install your app to get access tokens.
Finally, reveal your token and copy it.
2. Enable Login Log
Once you retreave the token, navigate to Apps > Magefan Login as Customer > Configuration and paste it in the Login Log section.
3. Contact Shopify support
Write to Shopify Plus support and ask them to enable read_users to access the scope of the custom app you've just created. Once they do that, you'll see the admin user and time when they logged into a corresponding customer account.
This way you'll track admins' activity better and provide better support correspondingly.