Purpose of this document

Before you can develop or test your Mobify powered adaptive website, the Mobify tag needs to reside under the <head> tag in your desktop HTML. If you cannot place the tag into your production or staging website, tag injection provides an alternative mechanism to continue site development until the tag can be deployed. Tag injection is only for development, you cannot use tag injection as a production solution.

Tag injection is a work-around for not having the tag installed. It is always preferable and simpler to have the tag installed directly in your site.

By default new projects use Mobify's tag injector service to inject the Mobify tag into your HTML. To inject the tag, your site is passed to our tag injector as a subdomain:


This document explains how tag injector works and how to run it on your local machine.

How tag injector works

Tag injector

  1. receives a request for a URL
  2. downloads the HTML from that URL
  3. inserts the Mobify Tag into the head of the HTML
  4. returns the new injected HTML

Common problems with tag injector

Proxying your site through our standalone tag injector service can cause some problems:

  1. Tag injector is located in Amazon's EC2 data centers. If your desktop site blocks IPs from Amazon's network, tag injector may not be able to access your page resulting in a server error.
  2. As your content is now being fed through a proxy server, cross-domain resource issues may arise. AJAX requests are particularly problematic through a proxy server due to Cross-origin resource sharing.

Remember: Tag injection is a work-around for not having the tag installed. It is always preferable and simpler to have the tag installed directly in your site.

Why use local tag injection?

Local tag injection will act as a tag injecting proxy server on your local machine. If IP blacklists are an issue, local tag injection will solve this problem. Also, running tag injector locally allows you to serve up your site's HTML from the same URL.

Running tag injector

Mobify Client contains a local version of tag injector. To run it, enter this command in your project directory:

mobify preview -t

You may have to run it with sudo. Preview will start up with the following output:

Running Preview at address and port 8080
Running Tag at
Running Tag at
Press <CTRL-C> to terminate.

You are now running tag injector and previewing your project from your local machine!

To take advantage of tag injector, we now need to run requests through it. You can use proxy software such as Charles Web Proxy or Fiddler to funnel requests for your site through your local machine. As tag injector is receiving requests on your local machine, once the proxy has been configured, all requests to your URL will run through tag injector.

Modifying your hosts file

There is another way to use tag injector locally which does not require any external software.

First, you will need to run tag injector on another computer or network interface. Then, modify your hosts file as follows:

...    yoursite.com

Rackspace has a good tutorial for how to modify your hosts file with instructions for Windows, Linux and OS X. Don't forget to fix your hosts file when you're done or you'll find yourself getting confusing results when you're ready to test against production!

Modify the IP to point to the computer that you are running tag injector on. Now, your modified hosts file will point to an internal tag injector running on a computer in your network, injecting the tag into your site transparently. Note: Running tag injector on your local machine with a modified hosts file will cause an infinite loop of tag injector looking for your URL on your local machine, which will in turn access tag injector again, forever.

Last Edited