If this is your first visit, check our documentation. To post, register or login.
Forums / Business Issues / Other Business Topics / Google Sitelinks Searchbox - is this the right way?

Google Sitelinks Searchbox - is this the right way?

Started by mesnitu on 6 Jul 2016, 2:24 PM · Views: 110

Results 1 to 12 of 12
6 Jul 2016, 2:24 PM
#1
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Google Sitelinks Searchbox - is this the right way?

Hi
Not sure if this is the right place to post this, but I've become aware of a Sitelinks Searchbox using the schema markup, etc....
ok. I've done so ( this is a partial code of json /ld file :

 <?php if ( $this_is_home_page ) { ?>
          "potentialAction": {
          "@type": "SearchAction",
          "target": "<?php echo $canonicalLink; ?>index.php?main_page=advanced_search_result&search_in_description=1&keyword={search_term_string}",
          "query-input": "required name=search_term_string"
          },
    <?php } ?>

Testing this , I get no errors... but I also don't see no results and probably will take time.
So just to ask, if anyone has done this, and if the "target" link is ok .

...oh, and is it wise to have this only in the home page ? I don't even remember why I've done so using the if ( $this_is_home_page )

Tahnks

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

7 Jul 2016, 9:18 AM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Google Sitelinks Searchbox - is this the right way?

mesnitu:

Hi
Not sure if this is the right place to post this, but I've become aware of a Sitelinks Searchbox using the schema markup, etc....
ok. I've done so ( this is a partial code of json /ld file :

<?php if ( $this_is_home_page ) { ?>
      "potentialAction": {
      "@type": "SearchAction",
      "target": "<?php echo $canonicalLink; ?>index.php?main_page=advanced_search_result&search_in_description=1&keyword={search_term_string}",
      "query-input": "required name=search_term_string"
      },
<?php } ?>
> 
> Testing this , I get no errors... but I also don't see no results and probably will take time. 
> So just to ask, if anyone has done this, and if the "target" link is ok .
> 
> ...oh, and is it wise to have this only in the home page ? I don't even remember why I've done so using the  if ( $this_is_home_page ) 
> 
> Tahnks

Where are you placing this code?    If placed in one of the usual .php files, this is just going to display 'code'  if on the home page. On any other page, it isn't going to do anything.   

I acknowledge that you stated this is just 'partial code',  but for this code to be doing anything 'useful' it is going to need to be used in conjuction with the javascript that is associated with it.   Is the javascript even being loaded?    

As for the target link -  its impossible to say for sure, but if this code is in its own .php file (which I'm kinda guessing it should be), you will probable need to add a line like 
global  $canonicalLink ;      

... but even then I can't say if the $canonical link is what is needed or not.  My gut is telling me 'no'.    The $canoniical link may not even have been set when this .php file is called.  

Is this from a zencart module, or are you following instructions from elsewhere? 

Perhaps if you could supply more info about the module/source/installation guide one of us will follow through with it a little further, but as it stands, all we really have is "This is a little bit of code that is supposed to do something, but isn't working. What's wrong with it"  

We need something more substantial.  

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

7 Jul 2016, 9:46 AM
#3
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Google Sitelinks Searchbox - is this the right way?

Hi
Right.
Well, i'm including this file for extra metatags in common/html_header.php so the canonical link it's there.

I didnt' past the total code because the rest is related to other shema markups using json/ld
That bit related to Google Sitelinks Searchbox looks like .... ("isolated" ?) , I mean, it's not related to the rest.

https://search.google.com/structured-data/testing-tool

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebSite",
  "url": "https://www.example.com/",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "https://query.example.com/search?q={search_term_string}",
    "query-input": "required name=search_term_string"
  }
}
</script>

Anyway this is the all the code with what I think the "target" query is ( EXAMPLE.COM/index.php?main_page=advanced_search_result&search_in_description=1&keyword={search_term_string}",) :
But, like there are no immediate results... I wonder if anyone is using this and gets results.

<script type="application/ld+json">
      {
      "@context" : "http://schema.org",
      "@type" : "LocalBusiness",
      "@id":"<?php echo $canonicalLink; ?>",
      "name" : "<?php echo STORE_NAME; ?>",
      "image" : "<?php echo $og_image; ?>",
      "url": "<?php echo $canonicalLink; ?>",
      "sameAs" : [ "<?php echo FACEBOOK_PAGE; ?>","<?php echo GOOGLE_PAGE; ?>","<?php echo TWITTER_PAGE; ?>"],  
    <?php if ( $this_is_home_page ) { ?>
          "potentialAction": {
          "@type": "SearchAction",
          "target": "<?php echo $canonicalLink; ?>index.php?main_page=advanced_search_result&search_in_description=1&keyword={search_term_string}",
          "query-input": "required name=search_term_string"
          },
    <?php } ?>
      "telephone" : "<?php echo META_TAG_PHONE_NUMBER; ?>",
      "email" : "<?php echo STORE_OWNER_EMAIL_ADDRESS; ?>",
      "address" : {
        "@type" : "PostalAddress",
        "streetAddress" : "<?php echo META_TAG_STREET_ADDRESS ?>",
        "addressLocality" : "<?php echo $og_zone; ?>",
        "addressRegion" : "<?php echo $og_zone; ?>",
        "addressCountry" : "<?php echo $og_country; ?>",
        "postalCode" : "<?php echo SHIPPING_ORIGIN_ZIP; ?>"
      },
        "geo":{
        "@type":"GeoCoordinates",
        "latitude":0,
        "longitude":0
      },
        "openingHoursSpecification": [
      {
      "@type": "OpeningHoursSpecification",
        "dayOfWeek": [
            "Monday",
            "Tuesday",
            "Wednesday",
            "Thursday",
            "Friday",
            "Saturday",
            "Sunday"
      ]
  }
      ]
      }
    </script>

Thanks

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

7 Jul 2016, 1:34 PM
#4
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Google Sitelinks Searchbox - is this the right way?

Suggestion. Forget about tge canonical link
Try something like this

target": "<?php echo "http://yourdomain/index.php?main_page=advanced_search_resul... the reason being is that the cannoical link could well be http://yourdomain/index.php, so the string being echoed will end up as http://yourdomian/index.php/index.php?mainpage.....

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

7 Jul 2016, 1:41 PM
#5
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Google Sitelinks Searchbox - is this the right way?

Ps. I have installed this on a customers site, but it was a couple of years ago (I thought the code looked a little familiar, but could remember where from until now)... customer didnt like it (can't remember why, but I think it may have been because it was inserting adverts into the results, and needed a payment to suppress them. It was a very short lived experiment on my part, and never revisited..

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

8 Jul 2016, 5:59 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Google Sitelinks Searchbox - is this the right way?

This is what I've used:
/includes/modules/pages/index/jscript_sitelinks_homepage.php

<script type="application/ld+json">{
  "@context": "http://schema.org",
  "@type": "WebSite",
  "url": "<?php echo zen_href_link(FILENAME_DEFAULT, '', 'SSL'); ?>",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "<?php echo zen_href_link(FILENAME_ADVANCED_SEARCH_RESULT, 'keyword={search_term}&search_in_description=1', 'SSL'); ?>",
    "query-input": "required name=search_term"
  }
}
</script>

... and is what's in the next version of Zen Cart: https://github.com/zencart/zencart/pull/166/files

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Jul 2016, 12:42 PM
#7
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Google Sitelinks Searchbox - is this the right way?

ok
Thank's, I'll be doing the changes here.

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

16 Jul 2016, 12:50 PM
#8
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Google Sitelinks Searchbox - is this the right way?

...another thing a litle of topic of the Google Sitelinks Searchbox :

I've more or less divided markup into 2 sections, the products page and all the others.
So the products page as all the product info , and the other the business info.

But this Google Sitelinks Searchbox should be on all pages ? Or just in the home page ?....
thanks

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

16 Jul 2016, 12:56 PM
#9
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Google Sitelinks Searchbox - is this the right way?

mesnitu:

But this Google Sitelinks Searchbox should be on all pages ? Or just in the home page ?....
thanks

Surely this is a matter of personal preference?

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

16 Jul 2016, 1:03 PM
#10
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Google Sitelinks Searchbox - is this the right way?

RodG:

Surely this is a matter of personal preference?

Cheers
RodG

I dont' know.... I mean, I think it doesn't matter, but it might. I'll be adding this piece of code on every page , just in case.

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

18 Jul 2016, 6:07 AM
#11
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Google Sitelinks Searchbox - is this the right way?

mesnitu:

I dont' know.... I mean, I think it doesn't matter, but it might. I'll be adding this piece of code on every page , just in case.
ZC will only be putting it on the home page.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

8 Nov 2017, 9:11 AM
#12
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Google Sitelinks Searchbox - is this the right way?

Hi
I'm not getting no results, have you tried this verification as mentioned in google developers ?

"Verify your search engine implementation by copying the WebSite.potentialAction.target URL from your structured data, replacing search_term_string with a test query, and browsing to that URL in a web browser. For example, if your website is example.com, and you want to test the query "kittens", you would browse to https://www.example.com/search/?q={kittens}"

I'm getting a zencart warning that no search term was introduced

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison