How I Automated My Instagram Marketing Campaign By Coding a Javascript Bot.

Uddeshya Agrawal
3 min readMay 18, 2020

--

Photo by Rock’s Roll Monkey on Unsplash

Instagram is one of the best platforms when It comes to market your app and reach audience organically. One of the best ways to get attention is to follow your target users according to the hashtag or location. In my case it was a Mobile Game.

I found all the posts with #bored in them and followed the users who posted it. Some of them opened my profile and my good content made them download my game from the store. The good strategy for starting right?

But doing this manually? Yeah, It can be done manually but then what’s the benefit of being a programmer? 👿
The programmer inside me was frustrated to do the whole process manually so I wrote a script that follows each user one by one at the interval of 22 seconds so Instagram does not block me up.

Here is how to do it -:

  1. Open Instagram and search for the HashTag you want to target.
  2. Open anyone post in the following hashtag and inspect the follow, like, and next buttons. Copy their class names. Try to use up to their second or third class.
  3. Now Create a variable that selects these elements in the DOM.
  4. Run function that clicks the selected elements at certain times.
  5. Write a script that executes every 22 seconds which first likes the post. Then follows that account. Then Goes to the next page.
  6. You have to run this script in Google Chrome’s console.

const like = document.querySelector(`button.wpO6b._8-yf5 `); //like button
const next = document.querySelector(`a._65Bje.coreSpriteRightPaginationArrow`); //next button

setInterval(function()
{
if(like)
{
like.click() //Likes the post.
} var button = document.querySelector(‘button.oW_lN.sqdOP.yWX7d.y3zKF’);
console.log(“success”);

button.click();
next.click();
}, 22000); //timer

You can modify this code to make comments also on every post. Just select the text area and append the text and click the submit button from the console.

I will cover the comment feature too in my next article.

You can modify the code to make it look better, As for me, I didn’t give much time to write this script. Hardly 5 minutes.

My team has developed a mobile game and since we are a bit tight on Budget we are doing all sorts of Organic Marketing. Instagram and Facebook are one of them. I am trying to automate as much process as possible and will keep them posted here so It can help others like me who are low on marketing budgets.

If you want to help me download the game here :)

It’s a game where you can drool down your childhood memory and play your favorite game BINGO !! Let’s Bingo !! It’s free to play and you can win $50 directly into your PayPal and Venmo account :D. The game is scheduled each day at 4 pm PST.

Need to add few changes in this code to avoid spam detection :

  1. Add a cron that runs this function after 1 hour if the code is executed 20 times successfully else Instagram will block you for 1 hour.
  2. Add a feature to change hashtag after every 20 executions.
  3. Add a feature to leave different comments on Post that has been liked.

Pardon my quick explanation as I wrote this article in a Time Crunch.

Thanks.

--

--

Uddeshya Agrawal
Uddeshya Agrawal

Written by Uddeshya Agrawal

Developer turned entrepreneur . Enabling Enterprise Companies and Businesses to optimize results through various technology and digital experimentation.

No responses yet