show multiple result for single page Google custom search - google-custom-search

I have single page application in which I want to apply Google custom search. What my requirement is when I search something then it will show result from each section of the page. I have created anchor tag links whenever click on them it will redirect me to that section of the page.
What I try till now I applied code which comes from while creating search engine here is my code:
(function() {
var cx = 'xxxxxxxxxxxxxxxx:xxxxxxxxxx'; //my engine id
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
Thanks for the help!

Related

is there a way to add LinkedIn insights code so it gets properly triggered in Vue

is there a way to add LinkedIn insights code so it gets properly triggered in a Vue project? or does adding the code before the closing body tag suffice?
If you want to include LinkedIn insights code into the whole app then use it in the main.js file. Else you can use where you want for specific pages.
Below is the example code that you can use and it will work.
(function () {
var s = document.getElementsByTagName("script")[0];
var b = document.createElement("script");
b.type = "text/javascript";
b.async = true;
b.src = "https://snap.licdn.com/li.lms-analytics/insight.min.js";
s.parentNode.insertBefore(b, s);
})();
window._linkedin_partner_id = "0000000"; //paste your id here
window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];
window._linkedin_data_partner_ids.push(window._linkedin_partner_id);

Google button doesn't appear

Google +1 button don't want to appear.
I follow the method here: https://developers.google.com/+/web/+1button/
a post on my blog for example: http://misapuntesde.com/post.php?id=256
It's like post.php was a blacklisted page (it doesn't), because I copy/paste the same page to post_t.php and it works.
Google does not like me :(
I'm not seeing the +1 button rending on your page sources. Something you are doing in your PHP code is not rendering the JavaScript include or the +1 markup.
Try adding this code to your site before your closing </body> tag:
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
Next, add the following code where you want the +1 button to render:
<div class="g-plusone" data-annotation="inline" data-width="300"></div>

Google Plus button displaying wrong count

The Google+ button http://www.amayzinghomes.com is displaying the wrong count. This is a brand new domain so it should only be showing a few clicks. I think it may be displaying the number of clicks on the Google Plus page where I got the script instead of the count for the actual page it's on. Here's the script I used:
<!-- Place this tag where you want the +1 button to render. -->
<div class="g-plusone" data-size="tall" data-href="http://www.amayzinghomes.com/"></div>
<!-- Place this tag after the last +1 button tag. -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
s</script>
The most likely explanation is that the count of 7 comes from links shared on Google+.
I do see one public post via this search:
https://plus.google.com/u/0/s/amayzinghomes
There may be private posts with that URL too.
I have the same problem, https://plus.google.com/116401211377269068112 shows count over 180 while the JavaScript plugin shows only 13 on www.ceriseshirts.com . The code is given below
<div class="g-plusone" data-size="medium" data-annotation="bubble" data-width="60" data-height="69" data-href="https://plus.google.com/116401211377269068112"></div>
<script>
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>

Google Analytics custom variables not showing on reports

I "inherited" this code that is using Google Analytics to track errors using custom variables but they are not showing up on the Google Analytics website. Unfortunately the guy who implemented this no longer works here and no one else knows how it works or can even tell me if these custom variables used to work. I have been reading the documentation and examples on this site and it appears he has it correct. Here is the code minus the account number:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXXX-1']);
_gaq.push(['_setCustomVar', 1, 'ErrorCode', 'BadPassword-05', 3]);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
This code is in the tags before any other javascript. When I go to the Google Analytics site I can see 18,000 visits and it shows me all of the URL information but when I go to Audience->Custom->Custom Variables it doesn't show anything and says there is "no data for this view". From what I understand from the documentation and my web searches that this is where the data should be. Can anyone give me advice on how this works or based on the code if the previous developer even coded it correctly?
This code stores a Custom Variable on the "page" scope ('3' as the last value), and the current GUI, there is no standard report showing page level custom variable reports.
You need to build a Custom Report (table format), with Custom Var value and Page.
This should show you the collected data.

Is it allowed to minify Google +1 button and Twitter's follow button?

I recently added a +1 button and the new Twitter's follow button and I would like to minify them.. Is minifying the button's script's is allowed?
It means that i would like to minify this for twitter:
<script type="text/javascript"> (function(){
var twitterWidgets = document.createElement('script');
twitterWidgets.type = 'text/javascript';
twitterWidgets.async = true;
twitterWidgets.src = '//platform.twitter.com/widgets.js';
document.getElementsByTagName('head')[0].appendChild(twitterWidgets);
})();
</script>
and this for google+:
<script type="text/javascript"> (function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script
I tried to check it out in thier FAQ section, but couldn't find anything.
Thanks in advanced, Din.
You can minify them if you want but minifying the dozen lines isn't going to make much of a difference. The amount of effort to minify them is probably more effort then the gain you will get.