Bower component installation directory change

To change the bower’s component installation directory as you want you first need to create a .bowerrc file and define the custom location in this .bowerrc like the below.

{
    "directory": "yourCustomDirectoryLocation"
}

 

Then as usual just make a bower.json file where you will write down all the dependencies for your projects like the below.

{
  "name": "YourProjectName",
  "description": "Description of your project",
  "homepage": "http://yourProjectUrl.com/",
  "author": "Yourname <your@email.com>",
  "dependencies": {
      "bootstrap":">= 3.0.0",
      "jquery": "~2.0.3"
  }
}

 

now run bower install command and all the required dependencies will be installed to your defined directory (as you configured in your .bowerrc file).

Add Google places address suggestion in your address field

To avoid misspelled user typing of address for searching places or anything by Google map, you can place only address suggestion dropdown provided by Google places API. It’s so easy to integrate.

Just add the following Javascript code before </head> tag.

<script src="https://maps.googleapis.com/maps/api/js?sensor=true&libraries=places"></script>

Now let’s assume your input field/ address field code in your form is-

<input type="text" class="form-control" id="locationInput" placeholder="write your address">

 

Now put the following javascript code after adding the google api javascript file source.

<script>
  (function(){
    var options = {
                    types:  ['geocode']
                  };

    var input1 = document.getElementById('locationInput');
    var autocomplete = new google.maps.places.Autocomplete(input1,options);
  })();
</script>

Now when you will try to type something on your address field then automatically google will show possible address suggestions for you.

Get value and read value of a DIV in jQuery

Sometimes it can make you questioned that to get value and to assign value of a DIV using jQuery can be performed by only one function and that is-

$("#ElementID").val()

With the same code as above we can assign value for this element in jquery..

$("#ElementID").val("The Value")

the difference is to give argument in jquery val() function or not.

But remember my last code will only assign value inside jquery operation. But text inside that element will not be changed.

Click Tracking – How to track click with Google Analytics

How to track click in Google Analytics

Since long days I was looking for a perfect system to track clicked link in my company website and at last I made the solution.
[adsense_id=”2″]
Basically it’s easy to track click with the help of Google Analytics, jQuery or simple javascript. My solution has given below-

<!–Google Analytics Code–>
<script type=”text/javascript”>
var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, ‘UA-17736742-1’]);
_gaq.push([‘_setDomainName’, ‘previewict.com’]);
_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>
<!–End analytics–>

 

<script type=”text/javascript”>
//This is the extra code to track click
$(document).ready(function(){
$(“a[href^=’http://’]”).click(function(){
//pageTracker._trackEvent(“links”, “TestPurpose”, $(this).attr(“href”), 0);
//_gaq.push(“links”, “TestPurpose”, $(this).attr(“href”), “Preview ICT”);
url = $(this).attr(‘href’).replace(/^#/, ”);
_gaq.push([‘_trackEvent’, ‘WEBService’, ‘click’, $(this).attr(‘href’)]);
});
});
</script>

The last portion of the above code is the solution to track all <a> tag’s href value which will be clicked. it’s the mechanism of Google Analytics Event tracking feature. I have tested it and successfully I can track link now.

[adsense_id=”3″]
Before placing the code inside you <head> tag you must add Jquery script above all this code. You can use?https://www.previewict.com/web/js/jquery-1.6.2.min.js?this link or you can use your latest jQuery framework to run the above code precisely.
After placing the code inside <head> tag you can be able to see the clicked event tracking report from your Google Analytics ‘Custom Reporting’->Content->Event->Overview like the below image-
That’s all.

To know more details about Google Analytics you can follow me on the following social site-

Follow me on G+ For Bangladesh

Don’t forget to add me in your Google+ circle and don’t forget to bookmark this webpage coz I will write lots of writes up here regarding many interesting feature of Google Analytics.

 

Starting to write JavaScript in Webpage

To start writing JavaScript in your HTML page, it’s really easy. Just start to write <script type=”text/javascript”> and make a end of this javascript code snippet by </script> closing tag. Try to have a look as following and open your notepad and start writing HTML page with the following little bit JavaScript code snippet.

<html>
<body>
<script type=”text/javascript”>
document.write(“Hello World!”);
</script>
</body>
</html>