mindgeekblog
mindgeekblog
MindGeek #SimplyTechnology
57 posts
Don't wanna be here? Send us removal request.
mindgeekblog · 6 years ago
Text
Solved: Tracking Virtual PageView via Google Tag Manager
Tumblr media
What is the requirement of Virtual Page Views?
While working on a single page website(SPA) or any JavaScript based(ReactJS, AngularJS, BackBoneJS, etc) websites, the interactions of user actions are not straight forward and most of the content is rendered via JavaScript AJAX calls, without reloading the page.
Virtual Pageview: It's not really a page view but are user actions which are tracked like the real page views. Some examples of them are: - Infinite Scroll, Load more, Pagination.
- Lightbox, Modal box.
Events which are the core feature of Google Analytics allows tracking user interactions based on specific triggers. Now, I'll Show you how you can track the virtual pageviews with GTM(Google Tag Manager) V2:
1. Firstly, we need to setup Google Tag Manager and its container.
2. Setup GTM Data Layer Variables required:
Tumblr media
Go to Variables -> User Defined Variables -> New
Setup variable named "virtualPageURL":
Tumblr media
Setup variable named "virtualPageTitle":
Tumblr media
Here the variables created for Virtual Pageview:
Tumblr media
3. Setup GTM Virtual PageView Trigger:
Go to Triggers -> New
Choose Event as "Custom Event" and complete the required details:
Tumblr media
4. On the website put the tracking javascript as per the requirement(load more, ajax infinite scroll, lightbox):
<script type="text/javascript">   dataLayer.push({      'event':'VirtualPageview',      'virtualPageURL':'/category/news/page/2',      'virtualPageTitle':'News Page - 2' }); </script>
5. Finally Setup the GTM Virtual PageView Tag:
Go to Tags -> New
- Create a Google Universal Analytics Tag.
- Insert Tracking ID
- Track Type: Page View
- Expand More settings, Fields to set:
Tumblr media
page : {{virtualPageUrl}}
title: {{virtualPageTitle}}
-  Select Firing Trigger to "Virtual Page View Trigger".
Tumblr media
Save and Publish.
Check Google Analytics Real-time Content Dashboard for the triggered page views now.
0 notes
mindgeekblog · 8 years ago
Text
SyntaxError: Use of const in strict mode
I’m working with node.js, and in one of my js files I’m using const in "strict mode". When trying to run it, I’m getting an error:
SyntaxError: Use of const in strict mode.
If this is happening in nodejs, it is due to the older version of nodejs. Update node by using,
1) Clear NPM’s cache:
sudo npm cache clean -f
2) Install a little helper called ‘n’
sudo npm install -g n
3) Install latest stable NodeJS version
sudo n stable
Update nodejs instructions taken from, http://stackoverflow.com/a/19584407/698072
0 notes
mindgeekblog · 8 years ago
Text
Web performance Optimization
Tumblr media
We optimize your website by analyzing the pattern of the website. By using improved methods of optimization we makes your web pages fly while rendering.
Some of the points from our checklist are:
By improving your code, optimizing JS for non-blocking while rendering.
Sharing the web page load(I/O) by using a CDN and Seprate Session and Caching servers.
By Using Caching technology like Varnish, aiCache.
Using shared network caching like Memcached, Redis.
Optimizing the structure of your website for faster rendering in browsers like IE.
Optimizing Database Servers like Mysql, PostgreSQL for dynamic websites.
Web Server Optimization for web servers like Nginx, Apache, IIS, Tomcat, IBM Http Server, JBOSS, Express.
Using right Headers for Cache Control.
Image Optimization and Compression.
0 notes
mindgeekblog · 9 years ago
Text
Get list of product attribute in Magento
# Get list of colors from Magento Installation
Let’s create a file called getcolors.php on Magento root folder.
require_once ( “app/Mage.php” ); umask(0); Mage::app(“default”); Mage::getSingleton(“core/session”, array(“name” => “frontend”)); $attribute = Mage::getSingleton(‘eav/config’)->getAttribute(‘catalog_product’, ‘color’); if ($attribute->usesSource()) { $options = $attribute->getSource()->getAllOptions(false); } print_r($options);
When you excute the file getcolors.php either from shell or browser, It will print the list of color used in product catalog.
0 notes
mindgeekblog · 9 years ago
Text
Mindgeek Video Commerce Engine
Tumblr media
youtube
Contact For more details.
0 notes
mindgeekblog · 9 years ago
Text
Change a product's attribute value without loading the entire product model
Tumblr media
Loading product in a collection and saving them again and again over will take lot of time. To make it quick there is an alternate solution available which uses the same function used by Update attributes action from the product grid:
Mage::getModel('catalog/product_action') ->updateAttributes(array($productId), array('attribute_code'=>'value'), 0);
0 notes
mindgeekblog · 9 years ago
Text
Parse query string in shell script
Tumblr media
Sometimes we have to integrate multiple languages like node.js/php/shell script into bash shell script and parse query string to array for supplying query string data for manipulation.
Here is the simple script which will help you to achieve that goal:
#!/usr/bin/env bash declare -A querydict populate_querystring_array () { query=”$1″ while IFS== read arg value do querydict[“$arg”]=”$value” done < <(echo “$query” | sed ‘s/&/\n/g’ ) }
q=’user=mindgeek&password=1234f’ populate_querystring_array “$q” printf “${querydict[user]}\n”
0 notes
mindgeekblog · 9 years ago
Text
Flickr: Computer vision at scale with Hadoop and Storm
Tumblr media
  Flickr: Computer vision at scale with Hadoop and Storm (Huy Nguyen)
from
Yahoo! Developer Network
0 notes
mindgeekblog · 9 years ago
Text
No package 'opencv' found
Tumblr media
If you are getting this error while compiling certain modules which requires opencv library which is causing the execution to be aborted.
For fixing it, you need to install lib-opencv using following command:
Ubunntu/Debian – sudo apt-get install libopencv-dev
Centos/Red Hat – sudo yum install opencv-devel
After you do so, pkg-config –cflags opencv and pkg-config –libs opencv will work as expected.
0 notes
mindgeekblog · 10 years ago
Text
Using underscore.js with node.js
Tumblr media
Underscore.js:
Underscore is a JavaScript library that provides a whole mess of useful functional programming helpers without extending any built-in objects. It’s the answer to the question: “If I sit down in front of a blank HTML page, and want to start being productive immediately, what do I need?” … and the tie to go along with jQuery‘s tux andBackbone‘s suspenders.
Underscore provides over 100 functions that support both your favorite workaday functional helpers: map, filter, invoke — as well as more specialized goodies: function binding, javascript templating, creating quick indexes, deep equality testing, and so on.
Source: http://underscorejs.org/
To install underscore.js in a node.js project use: npm install underscore
After installing it you can use underscore now on your node.js project as : var _ = require(‘underscore’);
Things you can do with _ :
1. Merge two json objects:
var obj1 = {foo:”bar”};
var obj2 = {name:”john”};
var merged = _.extend(obj1,obj2);
0 notes
mindgeekblog · 10 years ago
Text
Error: /lib64/libc.so.6: version 'GLIBC_2.14' not found
Tumblr media
Sometimes on your node.js project you have seen problems like “Error: /lib64/libc.so.6: version ‘GLIBC_2.14’ not found” by some npm modules.
Error: /lib64/libc.so.6: version ‘GLIBC_2.14’ not found
This error comes when the available version of glibc is not compatible by the node module.
So, if you still want to work with that module, you need to rebuild that module on your project.
To do this simply go to Github, Clone a repo for node module where its installed in project, may be in node_modules directory.
Inside the node_modules directory clone that repo:
Example- git clone https://github.com/node-xmpp/node-expat.git
Now go to the cloned module, cd node-expat
Then install all node module dependencies. – npm install
After installing it to a clean build for that module: – node-gyp rebuild
Voila! Use the module in your project now.
0 notes
mindgeekblog · 10 years ago
Text
XML into MongoDB - quick and dirty
Tumblr media
Import XML from various API’s to MongoDB.
import net.liftweb.json.Xml // converts XML to JSON import com.mongodb.casbah.Imports._ // To put stuff in Mongo import com.mongodb.casbah.MongoDB // To connect to Mongo import com.mongodb.util.JSON // To parse JSON into a MongoDBObject import net.liftweb.json._ // To output Lift JSON as actual JSON import scala.xml.XML // To load XML // load the XML val xml = XML.load("http://www.w3schools.com/xml/note.xml") // fire up mongo connection val con = MongoConnection() val col = con("test")("xmlTest") // convert the XML into a BasicDBObject val bdo:BasicDBObject = JSON.parse(pretty(render(Xml.toJson(xml)))).asInstanceOf[BasicDBObject] // and insert it col.insert(bdo) // check that it's there: col.find.foreach(println)
0 notes
mindgeekblog · 10 years ago
Text
Better way to load layout blocks outside of Magento
For loading Magento Layout Blocks externally or in a controller without any complexity, use this:
From external file, we need to initiate Magento session:
Mage::getSingleton(‘core/session’, array(‘name’=>’frontend’)); $session = Mage::getSingleton(‘customer/session’, array(‘name’=>’frontend’)); $layout = Mage::app()->getLayout(); $layout->getUpdate()->addHandle(‘default’)->load(); $layout->generateXml()->generateBlocks(); $top = $layout->getBlock(‘top.links’)->toHtml(); echo $top;
From internal controller:
$layout = Mage::app()->getLayout(); $layout->getUpdate()->addHandle(‘default’)->load(); $layout->generateXml()->generateBlocks(); $top = $layout->getBlock(‘top.links’)->toHtml(); echo $top;
0 notes
mindgeekblog · 10 years ago
Text
How to configure libstdc++ with GCC 4.8?
You need to tell your dynamic linker (it’s executed when you run your program) where to find the library. Set LD_LIBRARY_PATH to the path of the library (probably somewhere under /app/gcc/4.8.0/lib or something).
Use find /app/gcc/4.8.0 -name “libstdc++.so.6”. Add the directory to your LD_LIBRARY_PATH. e.g with the path I mentioned:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/app/gcc/4.8.0/lib (if you’re using a bourne-like shell which the default on Linux).
Then try to run your program.
Voila!!
0 notes
mindgeekblog · 11 years ago
Text
Openresty : Programming with Magento/Mysql - Get Inventory of Products REST API
Skills Requried – LUA, nginx, mysql
If you have nginx-openresty installed, open the vhost file of your domain, than follow this:
Let your REST API path is http://<your-domain>.com/getstockserv?p=123450,12145
where p is the parameter where all product ids of Magento Products has been supplied.
Now add this entry to the vhost file –
location ^~ /getstockserv { content_by_lua ‘ local mysql = require “resty/mysql”; local cjson = require “cjson”; args = ngx.req.get_uri_args(); local query = “select product_id from cataloginventory_stock_item where is_in_stock = 0 and product_id in (“.. args.p ..”)”; local db, err = mysql:new(); db:set_timeout(5000);
local ok, err, errno, sqlstate = db:connect{ host = “<Enter Mysql Hostname>”, port = 3306, database = “<Enter Database Name>”, user = “<Enter Mysql User>”, password = “<Enter Mysql Password>”, max_packet_size = 1024 * 1024 }; res, err, errno, sqlstate = db:query(query); ngx.header[“Content-Type”] = “application/json”; ngx.say(cjson.encode(res)); ngx.exit(ngx.HTTP_OK); return; ‘; }
Reload nginx : nginx -s reload
Voila!! Now you can get the inventory of products without using Magento.
0 notes
mindgeekblog · 11 years ago
Text
How to add a Volume to EC2 Instance?
Tumblr media
Go to EC2 console to create the volume and attach it to the instance, and then we’ll mount the volume to make it available.
– under Elastic Block Store, click Volumes. – Click on Create Volume – Select the General Purpose (SSD) volume type. – Wait for your Volume to be available. – Right click on it and select Attach Volume, Select the instance and specify an unused device name say /dev/xvdk
For making it available follow these steps:
[ec2-user ~]$ lsblk NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT xvdk    202:80   0   22G  0 disk xvda1   202:1    0    8G  0 disk /
here xvdk device is not mounted.
To Mount it – mkfs -t ext4 /dev/xvdk # mkdir /mnt/space # mount /dev/xvdf /mnt/space
Voila, You just added the volume to the system.
To check it, df -h
[ec2-user ~]$ df -h Filesystem            Size  Used Avail Use% Mounted on /dev/xvda1            7.9G  1.1G  6.8G  14% / tmpfs                 298M     0  298M   0% /dev/shm /dev/xvdk              22G     0   22G   0% /mnt/space
0 notes
mindgeekblog · 11 years ago
Text
How to make nginx works with Geo IP?
Tumblr media
NGINX GeoIP Installation:
Follow these steps to install GeoIP with nginx:
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
tar -zxvf GeoIP.tar.gz
cd GeoIP-1.4.8/
./configure
make
make install
echo ‘/usr/local/lib’ > /etc/ld.so.conf.d/geoip.conf
yum install gcc pcre-devel.x86_64 openssl-devel.x86_64
yum install readline-devel pcre-devel openssl-develWe are using openresty – nginx here:wget 
http://openresty.org/download/ngx_openresty-1.7.2.1.tar.gz
tar xzvf ngx_openresty-1.7.2.1.tar.gz
cd ngx_openresty-1.7.2.1
./configure –with-luajit –with-http_geoip_module
gmake
gmake installwget 
http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
 -O /usr/local/share/GeoIP/GeoIP.dat.gz
gunzip /usr/local/share/GeoIP/GeoIP.dat.gz
In nginx.conf  http block – geoip_country /usr/local/share/GeoIP/GeoIP.dat;Reload nginx – nginx -s reload
0 notes