How to get shop name inside embedded app.

Shopify Partner
3 0 0

Hi I am following tutorial.

I have obtained access token and stored it in database after install the app goes to myapp page.

Lets say user has already installed the app and goes to my app . How can I get the shop name in my embedded app so I can get its accesstoken and perform requests.

Since the app already is in iframe and to get access token from database I have to use shop name but how can I get that in iframe ?

Replies 5 (5)
Shopify Partner
98 0 17

You should see a GET request and its parameters. One of the parameters is the shop name.

In the tutorial, it's done in the following line:

1. $query = $_GET; 
2. $store = $query['shop'];

So $store is the shop name.
Shopify Partner
3 0 0

Thanks a lot Felix !

There is no good php api for detailed stuff support is good only for ruby on rails . I had figued this by checking there were iframe parameters but it good to be confident about things from a official person !

1 0 0
if (isset($_SERVER['HTTP_REFERER'])) {
	$referalUrl = $_SERVER['HTTP_REFERER']; 
	$qs = parse_url($referalUrl, PHP_URL_QUERY);
	if (!empty($qs)) {
	    parse_str($qs, $output);
	    $shop = preg_replace('/$/', '', $output['shop']); //get store name without fullurl
	    // TODO check for key existence
	    $_SESSION['shop'] = $shop; 


This code will return shop name everytime you logged in. Hope this will help anyone. This code works for me. 

$_SESSION['shop'] = $_GET['shop'];

works for first time only. When you logged in after logout, it doesnot return any value. 

Shopify Partner
98 0 17

Hello Zack,

just as a side note: I'm not an employee or "official person" of shopify.
Shopify Partner
49 3 6

Hey so to get the shop if ur using the next.js boilerplate code from shopify-cli

go to pages -> _app.js,  u'll get it in the ctx.query object in the getInitialProps method so just return it 

MyApp.getInitialProps = async ({ ctx }) => {
  return {


now u should be able to access it from props of MyApps class

class MyApp extends App {
  render() {
    const { Component, pageProps, host, shop } = this.props;
    return (
      <AppProvider i18n={translations}>
            apiKey: API_KEY,
            host: host,
            forceRedirect: true,
          <MyProvider Component={Component} shop={shop} {...pageProps} />