<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Harish on Medium]]></title>
        <description><![CDATA[Stories by Harish on Medium]]></description>
        <link>https://medium.com/@harishlyadav?source=rss-d0dfecfbae90------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QGp58gdzspcADx2Pn-Ctww.png</url>
            <title>Stories by Harish on Medium</title>
            <link>https://medium.com/@harishlyadav?source=rss-d0dfecfbae90------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 20:26:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harishlyadav/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[When to use ‘Git Rebase’ explained]]></title>
            <link>https://medium.com/@harishlyadav/when-to-use-git-rebase-explained-3c8192cba5c7?source=rss-d0dfecfbae90------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c8192cba5c7</guid>
            <category><![CDATA[rebase]]></category>
            <category><![CDATA[git-rebase]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Harish]]></dc:creator>
            <pubDate>Sun, 17 May 2020 21:15:28 GMT</pubDate>
            <atom:updated>2020-05-19T18:18:38.439Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K4anH9QzRcPqLCv-7HyiCQ.png" /><figcaption>Git-Rebase</figcaption></figure><p>In this post, we’ll understand what is git rebase, how it is different from git merge and when to use the rebase command. The git rebase command is one of those commands which can work magic for managing the future development of a product by simplifying git history but it can be disastrous if not used carefully. Essentially, git merge and git rebase do the same thing, i.e., bring the contents of two branches together. However both of these commands execute this change, in entirely different ways.</p><h3>Use caution</h3><p>Some things to keep in mind before you rebase:</p><ol><li>Never rebase commits that have been pushed and shared with others. The only exception to this rule is when you are certain no one on your team is using the commits or the branch you pushed.</li><li>Use rebase to catch up with the commits on another branch as you work with a local feature branch. This is especially useful when working in long-running feature branches to check how your changes work with the latest updates on the master branch.</li><li>You can’t update a published branch with a push after you&#39;ve rebased the local branch. You&#39;ll need to force push the branch to rewrite the history of the remote branch to match the local history. Never force push branches in use by others.</li></ol><h3>Concept of Git Rebase</h3><h4>Problem Statement</h4><p>Consider that our team just completed the production release from master branch. Now they have started working on a entirely new feature in one of the dedicate branch named as <strong>dev-feature01</strong> branch. However, some one found a bug in the production release. Therefore, one of the developers created a <strong>quickfix</strong> branch to fix the bug and merged his/her code into <strong>master</strong> branch. Now we need to bring together the <strong>master</strong> branch and <strong>dev-feature01</strong> branch.</p><p>Below is graphical summary of what commit tree looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P8HvnNGEgOp7uuw5Uvf-HA.png" /><figcaption>problem-statement-git-branches-with-different-history</figcaption></figure><h4>Solution 01: Git Merge</h4><p>The merge is the most widely used method. To incorporate changes from <strong>master</strong> branch to <strong>dev-feature01</strong> branch, first we need to checkout the <strong>dev-feature01</strong> branch and then merge the <strong>master</strong> branch:</p><pre>git checkout dev-feature01<br>git merge master</pre><p>Or, we can condense this to a one-liner:</p><pre>git checkout master dev-feature01</pre><p>Once, its successful, the result commit tree would look something like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bMfmJ0HjxtpR1tyT8-EV5w.png" /><figcaption>what-happens-after-git-merge</figcaption></figure><p>Merging is nice because it’s a <em>non-destructive</em> operation. The existing branches are not changed in any way. However, it adds an extra commit called merge commit. This is added every time we need to incorporate changes from other branches into this branch.</p><h4>Solution 02: Git Rebase</h4><p>As an alternative to merging, we can rebase the <strong>dev-feature01</strong> branch onto <strong>master</strong> branch using the following commands:</p><pre>git checkout dev-feature01<br>git rebase master</pre><p>This moves the entire <strong>dev-feature01</strong> branch to begin on the tip of the master branch, effectively incorporating all of the new commits in <strong>master</strong>. But, instead of using a merge commit, rebasing <em>re-writes</em> the project history by <em>creating brand new commits</em> for each commit in the original branch.</p><p>So our commit tree would look something like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z810gkDE9jR_fi0bT52eqA.png" /><figcaption>the-resultant-commit-tree-after-rebasing</figcaption></figure><p>So instead of commits E and F, we have the commits E’ and F’. Note that the commits E and F are still there in git history, but they are just not accessible any more.</p><h3>Benefits of Git Rebase</h3><p>The major benefit of rebasing is that we get a much cleaner project history. First, it eliminates the unnecessary merge commits required by git merge. Second, as we can see in the above diagram, rebasing also results in a perfectly linear project history — we can follow the tip of feature all the way to the beginning of the project without any forks. This makes it easier to navigate the git history of the project.</p><h3>The Golden Rule of Git Rebase</h3><p>Since git rebase command essentially re-writes git history, it should never be used on a branch which is shared with another developer (Unless both developers are kind of git experts). Or as its also said, never use the rebasing for public branches.</p><p>The rebase moves all of the commits in master onto the tip of <strong>dev-feature01</strong> branch. The problem is that this only happened in your version of the repository. All of the other developers are still working with the original master branch which they got initially. Since rebasing results in brand new commits, Git will think that your <strong>master</strong> branch’s history has diverged from everybody else’s. The only way to synchronize the two <strong>master</strong> branches is to merge them back together, resulting in an extra merge commit and two sets of commits that contain the same changes (the original ones, and the ones from your rebased branch).</p><p>To understand more, let’s consider below state of commit tree on same product on developer A, Central Server (GitHub, Bitbucket, VSTS etc.) and developer B:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7ZGs9BaYYA8J7U4ycPdVSQ.png" /><figcaption>git-commit-history-comparison-01</figcaption></figure><p>We can see that all 3 have same versions.</p><p>Now, consider that developer A breaks the golden rule by rebasing master branch with dev-feature01 branch. In this case, the resultant tree would look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a5_V-PS6xf_oUr6_inTIoA.png" /><figcaption>git-commit-history-comparison-02</figcaption></figure><p>As you can see, the commit tree of developer A is now different from others. Meanwhile, developer B has gone ahead and made another commit E to his/her version of repository. None of them has sync’d their code to the central server.</p><p>Let’s consider that developer A tries to sync his <strong>master</strong> branch to the central server. He’ll get denied because the his <strong>master</strong> branch is now different from the <strong>master</strong> branch in the central server. One solution for him/her is to push his branch forcefully to the central server using git push –force. It will essentially overwrites remote branch with his/her version.</p><p>Now, the developer B has to resync his <strong>master</strong> branch before he/she can sync his/her code. So git will first do a pull and then a merge in order to resolve code conflicts. This is what it will look like once its complete:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BshC_MNWQ3HPHFP9g7eQ3w.png" /><figcaption>git-commit-history-comparison-03</figcaption></figure><p>Developer B is now finally able to push code back into central server and then developer A has to resync his code to get the latest version. In the end, the commit trees would look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xSub_o2tpZzF_noV57QGlA.png" /><figcaption>git-commit-history-comparison-04</figcaption></figure><p>You can also notice duplicate commits in the repository — D and D’ , which have the same set of changes. The number of duplicate commits can be as large as the number of commits inside your <strong>rebased</strong> branch.</p><p>As you can see, it has become hard to understand the flow of commits from one branch to another branch.</p><h3>When to use Git Rebase</h3><p>Above illustration makes it look like that git rebase is essentially not good to work on public branches. However, git rebase can also be done on the same branch. By periodically performing an interactive rebase on local branch, you can make sure each commit mentioned in git history is focused and meaningful. This lets you write your code without worrying about breaking it up into isolated commits — you can fix it up after the fact. This process is also sometimes known as the local cleanup.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c8192cba5c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup GDPR Cookie Consent with Google Tag Manager]]></title>
            <link>https://medium.com/@harishlyadav/setup-gdpr-cookie-consent-with-google-tag-manager-279def6aada?source=rss-d0dfecfbae90------2</link>
            <guid isPermaLink="false">https://medium.com/p/279def6aada</guid>
            <category><![CDATA[gdpr-cookie-compliance]]></category>
            <category><![CDATA[gdpr-cookie-consent]]></category>
            <category><![CDATA[cookie-consent-manager]]></category>
            <category><![CDATA[cookie-consent-with-gtm]]></category>
            <category><![CDATA[consent-manager]]></category>
            <dc:creator><![CDATA[Harish]]></dc:creator>
            <pubDate>Sun, 03 May 2020 09:32:29 GMT</pubDate>
            <atom:updated>2022-11-19T16:30:31.474Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*aUMGmVFmgJv83yj9SebdQg.png" /><figcaption>GDPR Compliance</figcaption></figure><p>On May 25th 2018, General Data Protection Regulation (GDPR) came in effect, meaning that online businesses that get visitors from the European Union, must track visitor/user behavior and collect data more carefully, responsibly, and with consent. If you are using some tools/scripts on your website that are used to identify individuals and their data is processed by you or 3rd parties), that can be done only when a person gives consent. This also affects tracking codes that are managed in Google Tag Manager. So before you get the actual consent, all the tracking should be put on hold. In this guide, I’ll show you what solution did I choose and how I implemented GDPR cookie consent notification.</p><h3>GDPR is not a cookie legislation</h3><p>I’d like to point out a common misconception here. The General Data Protection Regulation only involves personal data. It does not say anything about cookies unless it contains personal data. If a cookie contains personal data, then GDPR applies to it (because of data).</p><h3>GDPR Cookie Consent Flow</h3><p>Let’s go to our main topic, cookie consent. Solution I’ve chosen is offered by <a href="https://www.consentmanager.net/">Consent Manager</a>. I’ll explain that in a moment.</p><p>Here’s the flow:</p><ul><li>A new visitor lands on a page and sees the cookie notification banner.</li><li>Banner offers to accept cookies or reject them. Until this moment no tracking tags are fired yet. A visitor still has the opportunity to act before cookies are stored in his/her browser.</li><li>If a visitor clicks <em>Accept all/Save+Exit (Shown after selecting purposes)</em> button, this is a consent.</li><li>The consent banner will block the visitor from using the website content until tracking is accepted or rejected.</li></ul><h3>What will the consent banner look like?</h3><p>A visitor lands on your website and this popup will appear. It cannot be closed or hidden unless a visitor accepts or rejects tracking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*6i7Q52nbjuFEP9LwcJCnIA.png" /><figcaption>Cookie Consent Banner</figcaption></figure><p>If a visitor gives consent, all tags will continue working as usual. If a user clicks <em>Customize your choice</em>, a preference center will open where all the tracking categories (e.g. functional group, marketing etc.) will be opt-out by default. A visitor will have to choose which ones he/she wants to give consent to.</p><p>How it’s look like..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*RdL7SfAfdT45s0Fx9wxrbw.png" /><figcaption>Preference Center</figcaption></figure><h3>ConsentManager for Cookie: Pros and Cons</h3><p>If you’re not sure whether this tool is right for you, here are the advantages and disadvantages:</p><p><strong>Pros</strong>:</p><ul><li>The design is pretty good, clear and customizable.</li><li>Preference Center and the ability to opt-out/in to separate categories of tracking cookies.</li><li>Pushes consent data and events to the Data Layer.</li><li>Scans the website for cookies using manual crawler.</li></ul><p><strong>Cons:</strong></p><ul><li>Setup flow was annoying sometimes, especially for new users who don’t know all ins and outs, yet.</li></ul><p>It took me some time to understand during the first implementation (a day or two).</p><p>In this guide, I’ll also give you tips on how to avoid possible blunders in order to implement the GDRP cookie consent.</p><h3>Create an account</h3><p>This is a very important. It’s simple to create a free <a href="https://www.consentmanager.net/">Consent Manager</a> account. Free account is valid for 14 days trial period. You can upgrade to higher packages, if you finalize to use Consent Manager for production site.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gPczRElgZpZpbbsrSbnbvA.png" /><figcaption>Create an Account form</figcaption></figure><p>You will need to fill in this form and submit. After a while you will receive confirmation email with user name and password.</p><p>Once you receive an email with a username and password, come back to this blog post and we’ll continue.</p><h3>Scan the website</h3><p>After you login with username and password, you should be redirected to this page. Screen might look different for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pvS7ov_RLIkHXgWrl1SWlg.png" /></figure><h3>Categorize purposes and vendors</h3><p>If your website is not dependent on earning from online advertising, you can choose to create classic purposes like function, marketing, preferences etc. click <strong>Purposes&gt; Add New Purpose.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f8KEOVEY1L8ssBSN_vT7Xw.png" /><figcaption>Add New Purpose Screen</figcaption></figure><p>you have option to set behavior of purpose on this screen and save it. Some purposes cannot be changed as it is set by provider. Purposes with my account looks something like below, one which is marked green are created manually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QM00ZCjXocwFa9B9tNzNnw.png" /><figcaption>Purposes List</figcaption></figure><p>Now lets whitelist vendors for consent, click <strong>Vendors&gt; Add Vendors. </strong>Find your vendors and click on whitelist checkbox, it will automatically add to vendors list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iVZRuaj_3xMMFwDOrJGFww.png" /><figcaption>Add Vendor Screen</figcaption></figure><p>You also have option here to assign purpose to vendor in dropdown. Please note <strong>CMP vendor ID</strong> here, it will be use later while setting tags in GTM. Vendors with my account looks something like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s9GgBmGtS7kfImySHVEobA.png" /><figcaption>Vendors List</figcaption></figure><p>Once your purposes and vendors setup is ready, you can now start designing your own cookie banner.</p><h3>Cookie Banner Setup</h3><p>On dashboard click <strong>Designs&gt; Add New Design. </strong>Customize it as per your need. You will be able to change its layout, colors, content, and behavior. I won’t go into details of all options, you can explore it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9nLQU76oHlgcjLYC0f29XQ.png" /><figcaption>Customize your design</figcaption></figure><h3>CMP Setup</h3><p>Create<strong> </strong>CMP manually without the Wizard you can set much more settings. Now go back to dashboard and Click <strong>CMPs&gt; Add New CMP.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ezqSghvn6Fo614YCx97eEQ.png" /><figcaption>Create New CMP Screen</figcaption></figure><p>Here you have to select cookie banner that was created above, and set privacy policy url of your site. I will not go into more details, you can explore more settings when you scroll down and set you preferences settings. once CMP is created, you will see screen like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FTmoLaxnACv_exgccpMyLA.png" /><figcaption>CMP List</figcaption></figure><p>Most important step here, In above screen, click on <strong>Get CMP Code </strong>and follow the instructions to integrate CMP setup into your website. You have to copy and paste script into website’s main page. Once you insert script into your website’s main page, you will see screen like below. We have completed with half part of story. Lets move on to next half part.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hTzROYqQuWCVoMCt8oGfYw.png" /><figcaption>Cookie consent design after integrating with your website</figcaption></figure><h3>Integrating CMP consent with Google Tag Manager</h3><p>In order to use consent information with Google Tag Manager (GTM), the CMP will push so called data layers into GTM. The CMP will create the following data layer variables:</p><p>cmpGDPR<br>cmpConsentString<br>cmpVendorsConsent<br>cmpCustomVendorsConsent<br>cmpGoogleVendorsConsent<br>cmpPurposesConsent<br>cmpCustomPurposesConsent</p><p>The event “cmpEvent” in combination with above variables can then be used as a trigger for the tag manager in order to know if/when to fire the codes.</p><p>In order to skip some of the manual steps, I have created a GTM Container or so called “recipe” that can be imported into your GTM account and will save your some time and might help avoiding some common mistakes. Download <a href="https://github.com/HarishYadav88/GTM-recipe/blob/master/gtm_workspace.json">Receipe</a></p><h3>Import GTM receipe</h3><p>Login to your GTM account and go to <strong>Admin &gt; Import container.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mu9Oi8UHwjSqlopi6bOMGw.png" /><figcaption>Container setting</figcaption></figure><p>When you click on red marked, its unique GTM Id looks like GTM-XXXXXXX, then you see script in popup that you need to add into you website’s main page again, follow instruction in popup where and how to add it.</p><p>Choose the receipe json file to be uploaded, choose the workspace into which the file should be imported and choose import option <strong>Merge</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*voloM8ehO3ItJwUgFEJNoQ.png" /><figcaption>Import Container Screen</figcaption></figure><p>Click on <strong>Confirm</strong> in order to finish the import. If you look closely on cards in above screen, number 5 in Tags card &amp; 4 in Triggers card is shown in modified cell but in your case it will be shown in new cell.</p><p>Once you import file you will see all your tags like screen below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mrlinuXaSNJICE30gpcAIQ.png" /><figcaption>Tag screen</figcaption></figure><p>I will not go through all tags, but I will try to explain one specific tag in more detail like Google Analytics and show you how consent works for it.</p><h4>Setup for Google Analytics Tag</h4><p>In GTM goto <strong>Variables &gt; New</strong> in user defined variable and click on configure</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A2XkYBI6VdpehMUdEYm9WQ.png" /><figcaption>Create New Variable Screen</figcaption></figure><p>Choose variable type <strong>Page Variables &gt; Data Layer Variable</strong>, set the Variable Name to cmpGDPR and do remember to set default value to 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*111_4uPZl5hBXeZgQJMXxg.png" /><figcaption>cmpGDPR variable</figcaption></figure><p>Repeat the steps above for all other variables that you require (usually cmpGDPR, cmpVendorsConsent, cmpCustomVendorsConsent)and set default value to blank for other variables.</p><p>You also need one more variable Google Analytics Settings and insert Tracking Id of your google analytics account. You should use this variable while setting tag for google analytics to fire.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ju2cA7d2RWXWxGqXKEa3Jg.png" /><figcaption>Google Analytics settings variable</figcaption></figure><p>Now go to <strong>Triggers &gt; New</strong> and click on configure. Use event Name cmpEvent and add custom events to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kcc2e7ckN6I4C5CuDY7sgg.png" /><figcaption>cmpEvent setup for Google Analytics</figcaption></figure><p>For each event at least two rules are necessary: cmpGDPR equals 1 and cmpVendorsConsents contains ... or cmpCustomVendorsConsents contains ... (see next step)</p><p>Set the event rules to <em>cmpVendorsConsent contains ,x,</em> where x is the ID of the vendor and/or <em>cmpCustomVendorsConsent contains ,x, where x</em> is the ID of a system- or custom vendor (vendor-IDs that start with &quot;c&quot; or &quot;s&quot;). The IDs for the vendors can be found under menu Vendors/Whitelist</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BIZdN7DXXE02DmTtWgpkSA.png" /><figcaption>Vendor ID List</figcaption></figure><p>Repeat the above step for each vendor and create a new trigger for each vendor. I shown you steps only for Google Analytics Vendor.</p><p>Apply the trigger to your tags and ensure that the tags do not fire with pageView event but <strong>only</strong> with the cmpEvent</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uk_a_Re8LjL2Q2eCSyitHA.png" /><figcaption>Tag for Google Analytics Vendor</figcaption></figure><p>We have set up tag Google Analytics to fire when user gives his/her consent for Google Analytics Vendor in Cookie Consent banner.</p><h4>Now it’s time for Demo</h4><p>Give your consent in cookie consent preference screen to vendor Google Analytics to fire and click on Save+Exit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*fWoUlVQY7NOIsfFaXtO3rg.png" /><figcaption>Give your consent to Google Analytics</figcaption></figure><p>Open Google Tag Manager in debug mode and click on cmpEvent in summary section at left. You will see Tag Google Analytics fired for above consent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0c-i4-ZEON5jx60lOUnLlw.png" /><figcaption>Google Analytics Tag fired</figcaption></figure><p>In next step you choose not to give your consent, uncheck Google Analytics checkbox and click on Save+Exit like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*sQWgLVbRigKGhzIU3wFEgw.png" /></figure><p>Again go back to debug mode, and what you see is Tag Google Analytics is not fired this time, as user has not given his consent for Vendor Google Analytics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kBQzqR6RvlmG4Bu2dcXDTg.png" /><figcaption>Google Analytics Tag not fired</figcaption></figure><p>I did above setup for Google Analytics, You can set up tags for other vendors as your Cookie banner consists of. For each vendors you have to create separate trigger condition to fire and you can attach that trigger with existing tags using trigger group.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=279def6aada" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>